How to get the DDL of a Tablespace in Oracle :

To find the DDL (Data Definition Language) of a tablespace in Oracle Database, we can work the DBMS_METADATA package.
A tablespace consists of one or more physical data files. DDL of a tablespace is a set of SQL commands used to define the tablespace’s structure and properties. DDL of a tablespace may need in our daily DBA activities to create same type of tablespace or migrating it to another database etc. We can find DDL of a table, index,view, function, procedure etc. This article will help you through the steps to get the DDL of a tablespace in Oracle Database.

Steps to find the DDL of a tablespace in Oracle:

Step 1: Connect to Database:

Connect to Oracle Database To find the DDL, you need to connect to an Oracle Database using SQL*Plus or any other tool that supports SQL queries. Once connected, enter the username, password, and database details to establish a connection.

login to oracle database

Step 2: Identify the tablespace :

Identify the tablespace for which you want to find the DDL, once you’re connected to the database, so here we want to find the DDL of TBS1 tablespace.

find the tablespace name

Step 3: Find the DDL of the tablespace :

Now that you have identified the tablespace. Here we are going to find the DDL of TBS1 tablespace.

Syntax:
select dbms_metadata.get_ddl('TABLESPACE','tablespace_name') from dba_tablespaces;
Example:
select dbms_metadata.get_ddl('TABLESPACE','TBS1') from dba_tablespaces;
DDL of a tablespace in Oracle

So here are the steps to find the DDL of a tablespace in Oracle database. Hope this helps..!! You can also checkout Oracle Doc for further reference.

This Post Has 3 Comments

Leave a Reply