0% found this document useful (0 votes)
179 views

Manage Tablespaces in A Container Database (CDB) and Pluggable Database (PDB)

This document discusses managing tablespaces in Oracle multitenant container databases (CDBs) and pluggable databases (PDBs). It shows how to create, alter, and drop tablespaces in the CDB root and PDBs. It also covers undo tablespaces, temporary tablespaces, and setting default tablespaces in CDBs and PDBs.

Uploaded by

Ahmed Nagy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views

Manage Tablespaces in A Container Database (CDB) and Pluggable Database (PDB)

This document discusses managing tablespaces in Oracle multitenant container databases (CDBs) and pluggable databases (PDBs). It shows how to create, alter, and drop tablespaces in the CDB root and PDBs. It also covers undo tablespaces, temporary tablespaces, and setting default tablespaces in CDBs and PDBs.

Uploaded by

Ahmed Nagy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Manage Tablespaces in a CDB

----------------------------
CONN / AS SYSDBA

SQL> SHOW CON_NAME

CON_NAME
------------------------------
CDB$ROOT
SQL>

CREATE TABLESPACE dummy


DATAFILE '/u01/app/oracle/oradata/cdb1/dummy01.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;

Tablespace created.

SQL>

ALTER TABLESPACE dummy ADD


DATAFILE '/u01/app/oracle/oradata/cdb1/dummy02.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;

Tablespace altered.

SQL>

DROP TABLESPACE dummy INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>

Manage Tablespaces in a PDB


----------------------------
SQL> CONN / AS SYSDBA
Connected.
SQL> ALTER SESSION SET CONTAINER = pdb1;

Session altered.

SQL> SHOW CON_NAME

CON_NAME
------------------------------
PDB1
SQL

SQL> CONN pdb_admin@pdb1


Enter password:
Connected.
SQL> SHOW CON_NAME

CON_NAME
------------------------------
PDB1
SQL>

CREATE TABLESPACE dummy


DATAFILE '/u01/app/oracle/oradata/cdb1/pdb1/dummy01.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;

Tablespace created.

SQL>

ALTER TABLESPACE dummy ADD


DATAFILE '/u01/app/oracle/oradata/cdb1/pdb1/dummy02.dbf' SIZE 1M
AUTOEXTEND ON NEXT 1M;

Tablespace altered.

SQL>

DROP TABLESPACE dummy INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>

Undo Tablespaces
----------------
CONN pdb_admin@pdb1

SELECT tablespace_name FROM dba_tablespaces;

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

SQL>

But we can see the datafile associated with the CDB undo tablespace.

SELECT name FROM v$datafile;

NAME

--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdb1/undotbs01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

SQL>

SELECT name FROM v$tempfile;

NAME

--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdb1/pdb1/temp01.dbf

SQL>
Temporary Tablespaces
----------------------
Management of the temporary tablespace in a CDB is unchanged from that of a non-CDB
database.

A PDB can either have its owner temporary tablespace, or if it is created without a
temporary tablespace, it can share the temporary tablespace with the CBD.

CONN pdb_admin@pdb1

CREATE TEMPORARY TABLESPACE temp2


TEMPFILE '/u01/app/oracle/oradata/cdb1/pdb1/temp02.dbf' SIZE 5M
AUTOEXTEND ON NEXT 1M;

Tablespace created.

SQL>

DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>

Default Tablespaces
----------------------
Setting the default tablespace and default temporary tablespace for a CDB is
unchanged compared to a non-CDB database.

There are a two ways to set the default tablespace and default temporary tablespace
for a PDB. The ALTER PLUGGABLE DATABASE command is the recommended way.

CONN pdb_admin@pdb1
ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE users;
ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE temp;

For backwards compatibility, it is also possible to use the ALTER DATABASE command.

CONN pdb_admin@pdb1
ALTER DATABASE DEFAULT TABLESPACE users;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

With both methods, you should be pointing to the appropriate container for the
command to work.

You might also like