您好,登錄后才能下訂單哦!
先關閉應用
1)查看用戶的默認表空間及臨時表空間
set lines 300
col username for a30
select username ,default_tablespace,TEMPORARY_TABLESPACE from dba_users where username='MESPRD';
-----------------------------------
USERNAME DEFAULT_TABLESPACE TEMPORAR Y_TABLESPACE
MESPRD HTTBS_MESPRD TEMP
2)查看該用戶的權限和角色
select privilege from dba_sys_privs where grantee='SYSADM'
union
select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='MESPRD' );
-----------------------------------
PRIVILEGE
CREATE CLUSTER
CREATE INDEXTYPE
CREATE OPERATOR
CREATE PROCEDURE
CREATE SEQUENCE
CREATE SESSION
CREATE TABLE
CREATE TRIGGER
CREATE TYPE
已選擇9行。
3)獲取獲得授予用戶權限的腳本
select 'grant '||privilege||' to SYSADM;' from (select privilege from dba_sys_privs where grantee='SYSADM'
union
select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='SYSADM' ));
4)執行腳本獲得刪除該schema下對象的腳本 mesprd為要刪除的schema
connect mesprd/MESPRD
spool E:\app\Administrator\del_mesprd.sql;
select 'alter table '||table_name||' drop constraint '||constraint_name||' ;' from user_constraints where constraint_type='R';
select 'truncate table '||table_name ||';' from user_tables;
select 'drop table '||table_name ||' purge;' from user_tables;
select 'drop index '||index_name ||';' from user_indexes;
select 'drop view ' ||view_name||';' from user_views;
select 'drop sequence ' ||sequence_name||';' from user_sequences;
select 'drop function ' ||object_name||';' from user_objects where object_type='FUNCTION';
select 'drop procedure '||object_name||';' from user_objects where object_type='PROCEDURE';
select 'drop package '|| object_name||';' from user_objects where object_type='PACKAGE';
select 'drop database link '|| object_name||';' from user_objects where object_type='DATABASE LINK';
spool off;
5)sqlplus連接到該schema下,執行如上獲得的腳本
執行前查看下該schema下的對象,執行后再次查看下該schema下的對象
@?\E:\app\Administrator\del_mesprd.sql;
SQL> select object_type,count(*) from user_objects group by object_type;
6)kill掉連接數據庫的session
select 'alter system kill session '''||sid||','||serial#||''' immediate;' from v$session where username='MESPRD';
7)刪除該schema
drop user MESPRD cascade;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。