oracle 刪除表空間及數據文件方法


--刪除空的表空間,但是不包含物理文件
drop tablespace tablespace_name;
--刪除非空表空間,但是不包含物理文件
drop tablespace tablespace_name including contents;
--刪除空表空間,包含物理文件
drop tablespace tablespace_name including datafiles;
--刪除非空表空間,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空間中的表有外鍵等約束關聯到了本表空間中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

 

 


以system用戶登錄,查找需要刪除的用戶:

--查找用戶
select * from dba_users;
--查找工作空間的路徑
select * from dba_data_files;
--刪除用戶
drop user 用戶名稱 cascade;
--刪除表空間
drop tablespace 表空間名稱 including contents and datafiles cascade constraint;

例如:刪除用戶名成為ABC,表空間名稱為ABC

--刪除用戶,及級聯關系也刪除掉
drop user ABC cascade;
--刪除表空間,及對應的表空間文件也刪除掉
drop tablespace ABC including contents and datafiles cascade constraint;

 

刪除無任何數據對象的表空間:
首先使用PL/SQL界面化工具,或者使用oracle自帶的SQL PLUS工具,連接需要刪除的表空間的oracle數據局庫。
確認當前用戶是否有刪除表空間的權限,如果沒有 drop tablespace,請先用更高級的用戶(如sys)給予授權或者直接用更高級的用戶。
用drop tablespace xxx ,刪除需要刪除的表空間。
刪除有任何數據對象的表空間
使用drop tablespace xxx including contents and datafiles;來刪除表空間。
注意事項:
如果drop tablespace語句中含有datafiles,那datafiles之前必須有contents關鍵字,不然會提示ora-01911錯誤


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM