--批量建表流程--
--1.创建用户--
--2.授予用户系统权限--
--3.创建表(包含表和主键约束)--
--4.授予用户相应的对象权限(为创建外键约束授予相应的references对象权限)--
--5.创建表的外键约束--
--6.批量插入数据--
--批量删除数据库表--
--1.删除foreign key--
select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||';' sql from dba_constraints where owner in
(select username from dba_users where default_tablespace='CIMMODEL')
and constraint_type='R'
union all
--2.删除primary key--
select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||';' sql from dba_constraints where owner in
(select username from dba_users where default_tablespace='CIMMODEL')
and constraint_type='P';
--3.删除indexes,tables--
select 'drop '||object_type||' '||owner||'.'||object_name||' purge;' sql from dba_objects where owner in
(select username from dba_users where default_tablespace='CIMMODEL');
--批量清空数据--
--批量禁用约束--
select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='R';
--批量清空表数据--
select 'truncate table '||table_name ||';' from user_tables;
--批量启用约束--
select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R';
--其他--
--批量更改表的列名--
select 'alter table '||owner||'.'||table_name ||' rename column "'||column_name||'" to '||upper(column_name)||';' from dba_tab_columns where table_name='LD_BB_XSTJB1';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23135684/viewspace-625364/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23135684/viewspace-625364/