日期:2014-05-16 浏览次数:20428 次
set define on set serveroutput on connect / as sysdba define schema = &1 -- Kill Session connecting to the schemas to be dropped Declare Cursor c_session Is SELECT s.sid, s.serial# FROM gv$session s JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id WHERE s.type != 'BACKGROUND' AND s.username = '&schema'); Begin For r_session In c_session Loop Execute Immediate 'ALTER SYSTEM KILL SESSION '''||r_session.sid||','||r_session.serial#||''''; End Loop; End; / -- Drop schemas Drop User &schema Cascade; set define off exit
chmod +x drop_schema.sql
$sqlplus /nolog @drop_schema.sql