drop user username cascade; select username, sid, serial# from v$session WHERE USERNAME=username; alter system kill session 'sid,serial#' 3.如果想要保險起見就先 ...
- 首先如果有用戶存在需要刪除用戶的
drop user username cascade;
- 如果刪除不了,可能情況當前用戶處於連接狀態,可以查找session
select username, sid, serial# from v$session WHERE USERNAME=username;
alter system kill session 'sid,serial#'
3.如果想要保險起見就先把當前用戶lock掉;
alter user username account lock;
4.如果當前需要刪除的表空間(臨時)還是別的用戶的預設表空間
select * from v$session
select username,default_tablespace from dba_users where username='用戶名';
如果還存在兩種處理方式:1.修改所查詢到的用戶預設表空間和臨時表空間
alter user naro default tablespace TABLESPACENAME;
alter user naro default temporary tablespace TEMPNAME;
5.至此即可刪除表空間(臨時)
drop tablespace TABLESPACENAME including contents and datafiles CASCADE CONSTRAINTS;
drop tablespace TEMPSPACENAME including contents and datafiles CASCADE CONSTRAINTS;
6.創建新的表空間(臨時)
create tablespace SPACENAME datafile 'E:\database\data' size 200M autoextend on next 200m maxsize 20480m extent management local;
create temporary tablespace TEMPNAME tempfile 'E:\database\temp' size 200M autoextend on next 200m maxsize 20480m extent management local;
7.創建用戶賦權和預設表空間
CREATE USER username IDENTIFIED BY NARO ACCOUNT UNLOCK
DEFAULT TABLESPACE SPACENAME TEMPORARY TABLESPACE TEMPNAME ;
8.賦權
GRANT CONNECT,RESOURCE TO username ;
GRANT DBA TO username ;
搞定!!!!!!