ORACLE刪除用戶的有的表的方法

首先咱們查詢oracle用戶下的全部表html

select * from all_tab_comments -- 查詢全部用戶的表,視圖等
select * from user_tab_comments   -- 查詢本用戶的表,視圖等
select * from all_col_comments --查詢全部用戶的表的列名和註釋.
select * from user_col_comments -- 查詢本用戶的表的列名和註釋
select * from all_tab_columns --查詢全部用戶的表的列名等信息(詳細可是沒有備註).
select * from user_tab_columns --查詢本用戶的表的列名等信息(詳細可是沒有備註).sql

 

一、若是有刪除用戶的權限,則能夠:oracle

drop user user_name cascade;ide

加了cascade就能夠把用戶連帶的數據所有刪掉。spa

首先查看當前用戶的默認表空間和臨時表空間htm

select default_tablespace,t.temporary_tablespace ,t.*from user_users t; 對象

或 select default_tablespace,t.temporary_tablespace ,t.* from dba_users tblog

而後找到當前用戶的權限角色,table

select * from user_role_privs;object

 

刪除後再建立該用戶。
--建立管理員用戶
create user 用戶名 identified by 密碼 default tablespace space_data(表空間名稱) temporary tablespace space_temp(臨時表空間名稱);
--受權
grant connect,dba to 用戶名;
--修改限額
ALTER USER "用戶名" QUOTA UNLIMITED ON SPACE_DATA(表空間名稱);

--查看全部用戶對象
select uo.object_name,uo.object_type from user_objects uo where uo.object_type<>'LOB' order by uo.object_type desc

 

二、若是沒有刪除用戶的權限,則能夠執行:

select 'drop table '||table_name||' cascade constraints;' 

from cat 
where table_type='TABLE'

將會輸出一批刪除表的sql語句,這些SQL語句執行一下就能夠了。(須要有drop table的權限)

 

出處:http://www.cnblogs.com/chshnan/archive/2012/02/07/2341694.html

相關文章
相關標籤/搜索