← Space Management
Oracle · Space Management
How to get the DDL for all tablespaces in Oracle
Extract the CREATE TABLESPACE DDL for every tablespace using DBMS_METADATA and spool it to a file for reuse.
Tested on11g12c18c19c21c23ai26ai
One-shot script that dumps CREATE TABLESPACE DDL for every tablespace in the database into a local file (ddl_tbs.sql). Useful when rebuilding a database elsewhere or scripting a cutover.
SET HEADING OFF
SET ECHO OFF
SET PAGES 999
SET LONG 90000
SET LINESIZE 1000
SET TRIMSPOOL ON
SPOOL ddl_tbs.sql
SELECT DBMS_METADATA.GET_DDL('TABLESPACE', tb.tablespace_name)
FROM dba_tablespaces tb;
SPOOL OFFspaceddldbms_metadatatablespace