首页 >

oracle怎么删除schema

数据库|Oracleoracle怎么删除schema
oracle
数据库-Oracle
jquery点击左右切换图片源码,vscode有64版本马上,ubuntu设置sshd,1g内存tomcat,爬虫公司近况,php日志收集框架,技术好的seo供应商lzw
oracle怎么删除schema
优美女性网站源码,vscode go插件详解,设置ubuntu界面,tomcat异常报告,sqlite连表修改语句,程序员爬虫自动登录教程,友盟推送 php,鹰潭网络seo价钱,马克斯电影网站源码,网页漂浮,美团外卖 html5模板lzw
oracle怎么删除schema
aspx页游源码,mac vscode配置c,ubuntu 设置市区,tomcat 启动任务,sqlite3 输出界面,爬虫爬取vip音乐犯法吗,php响应式网站,上海seo发展现状,旅游类网站模板免费下载,网页16×16小图标下载,网站正在建设 h5模板lzw
删除schema语法如下:

drop user username cascade;

oracle怎么删除schema

示例如下:

1)查看用户的默认表空间及临时表空间

set lines 300col username for a30select username ,default_tablespace,TEMPORARY_TABLESPACE from dba_users where username='MESPRD';-----------------------------------USERNAME   DEFAULT_TABLESPACE     TEMPORAR    Y_TABLESPACEMESPRD    HTTBS_MESPRD        TEMP

2)查看该用户的权限和角色

select privilege from dba_sys_privs where grantee='SYSADM'unionselect privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='MESPRD' );-----------------------------------PRIVILEGECREATE CLUSTERCREATE INDEXTYPECREATE OPERATORCREATE PROCEDURECREATE SEQUENCECREATE SESSIONCREATE TABLECREATE TRIGGERCREATE TYPE

已选择9行。

3)获取获得授予用户权限的脚本

select 'grant '||privilege||' to SYSADM;' from (select privilege from dba_sys_privs where grantee='SYSADM'unionselect privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='SYSADM' ));

4)执行脚本获得删除该schema下对象的脚本 mesprd为要删除的schema

connect mesprd/MESPRDspool 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视频教学》


  • 暂无相关文章
  • Posted in 未分类