sqlplus spool

mengbing1990發表於2016-10-14
sqlplus
SQL> set feedback off heading off term off;
SQL> set pages 0 trim on trims on lines 32767 long 999999;
SQL> set echo off;
SQL> spool PSDVIEW2.sql;
SQL> select 'GRANT SELECT ON DWMGRPRD.' || table_name || ' to PSDVIEW;'
 from DBA_tables WHERE OWNER = 'DWMGRPRD';  2
 


Spool off;
SELECT 'alter table '||TABLE_NAME||' enable constraint '||CONSTRAINT_NAME||';' FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE='R'
SELECT 'alter table '||TABLE_NAME||' disable constraint '||CONSTRAINT_NAME||';' FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE='R'
Select 'TRUNCATE TABLE '||OWNER||'.'||TABLE_NAME FROM DBA_TABLES WHERE OWNER='XXXX'

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29551564/viewspace-2126340/,如需轉載,請註明出處,否則將追究法律責任。

相關文章