此例是生成刪除Oracle數據庫中的所有視圖的操作,生成的腳本文件爲drop.sql
set echo off;
set heading off;set line 100;
set long 2000000000;
set longchunksize 255;
set wra on;
set newpage none;
set pagesize 0;
set numwidth 12;
set termout off;
set trimout on;
set trimspool on;
set feedback off;
set timing on;
spool dropall.sql;
select 'drop view '||tname||';' from tab where tabtype='VIEW';
spool off;
exit;
以上的語句寫入到一個sql腳本中,以delete.sql爲例,將上述的語句寫入到delete.sql中,通過sqlplus腳本執行,即可得到sql腳本文件drop.sql。
sqlplus腳本具體:
在shell腳本中寫入echo @delete.sql 表空間名 | sqlplus 用戶名/密碼
若要刪除表或者存儲過程等其他項,則將select 'drop view '||tname||';' from tab where tabtype='VIEW'; 修改爲對應的select語句