轉自https://www.cnblogs.com/chshnan/archive/2012/02/07/2341694.html
1、查看當前登錄的用戶的所有表:
select table_name from user_tables;
查看除了以 SYM_ 開頭的所有表:
select table_name from user_tables where table_name NOT LIKE 'SYM_%';
如果有刪除用戶的權限,則可以:
drop user user_name cascade;
eg:
drop user SIMON cascade;
drop user TEST cascade;
#加了cascade就可以把用戶連帶的數據全部刪掉
刪除后再創建該用戶。--創建管理員用戶
create user 用戶名 identified by 密碼 default tablespace space_data(表空間名稱) temporary tablespace space_temp(臨時表空間名稱);
eg:
create user SIMON identified by "123456"
default tablespace SIMON_DATA
temporary tablespace SIMON_TEMP;
create user TEST identified by "123456"
default tablespace TEST_DATA
temporary tablespace TEST_TEMP;
--授權 grant connect,resource,dba to 用戶名;
eg:
grant connect,resource,dba to TEST; --修改限額 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;
2、如果沒有刪除用戶的權限,則可以執行:
select 'drop table '||table_name||';' from cat where table_type='TABLE';
# 將會輸出一批刪除表的sql語句,這些SQL語句執行一下就可以了。(需要有drop table的權限)
select 'drop table '||table_name||';'
from cat
where table_type='TABLE'
and table_name LIKE 'SYM_%';
# 刪除表名以SYM開頭的表
select 'drop table '||table_name||';'
from cat
where table_type='TABLE'
and table_name LIKE '%TRIGGER';
# 刪除表名以TRIGGER結尾的
創建表空間的方式創建用戶
/*第1步:創建臨時數據表空間 */
create temporary tablespace SIMON_TEMP tempfile 'C:\simon\user_temp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
/*第2步:創建數據表空間 */
create tablespace SIMON_DATA
logging
datafile 'C:\simon\user_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
/*第3步:創建用戶並指定表空間 */
create user simon identified by "123456"
default tablespace SIMON_DATA
temporary tablespace SIMON_TEMP;
/*第4步:給用戶授予權限 */
grant connect,resource,dba to simon;
commit;