Oracle 12C: drop user and drop tablespace



SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
VCDMAN_TBSP
TEMP2

7 rows selected.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDBORCL                        MOUNTED
         4 PDBVCDB                        READ WRITE NO


NOTE: MUST MAKE SURE DOING THIS IN AN INTENDED DATABASE SINCE THE SAME TABLESPACE AND SCHEMA CAN EXIST IN OTHER CONTAINERS.


SQL> alter session set container=PDBVCDB ;

Session altered.

SQL> select tablespace_name from user_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP
UVCDB

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP
UVCDB

drop user UVCDB cascade;
Drop tablespace UVCDB including contents and datafiles;



SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP

1 comment:

  1. Sometimes Oracle drop user takes long time to execute. In that case killing session will help.Thanks for sharing, nice.

    ReplyDelete