先关闭应用
为坊子等地区用户提供了全套网页设计制作服务,及坊子网站建设行业解决方案。主营业务为成都网站设计、成都做网站、坊子网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
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;
新闻名称:oracle数据库删除用户(schema)操作
链接地址:http://cqwzjz.cn/article/pjpidj.html