신문지한장

[SQL] oracle schema 및 tablespace 삭제 추출문 본문

Oracle/sql&script

[SQL] oracle schema 및 tablespace 삭제 추출문

신문지한장 2023. 11. 30. 17:43
OS : CentOS7.9 (64bit)
DB : Oracle Database 11g ( Release - 11.2.0.4 ) [모든 버전 적용]

1. schema 삭제 추출문

select 'DROP USER ' || username || ' cascade;' From dba_users where account_status>= 'OPEN' order by created;

2. tablespace 삭제 추출문

select distinct 'DROP TABLESPACE ' || tablespace_name || ' INCLUDING CONTENTS AND DATAFILES;' 
from dba_data_files 
where tablespace_name not in ('SYSTEM','SYSAUX','USERS','UNDOTBS1','UNDOTBS2','DRSYS','RBS','TEMP','TOOLS');