denrepo

OracleObjects & schema

Generate DDL for a table and an index

Uses DBMS_METADATA to write the CREATE statements for a table and one of its indexes into ddl_list.sql in your current directory. Prompts for the owner, table and index names.

Prompts for input

Tested on 12c, 19c · verified Sep 2026

ora-get-ddl.sql
1SET VERIFY OFF2set heading off;3set echo off;4Set pages 999;5set long 90000;6 7spool ddl_list.sql8select dbms_metadata.get_ddl('TABLE',UPPER('&&table_name'),UPPER('&&owner')) from dual;9select dbms_metadata.get_ddl('INDEX',UPPER('&index_name'),UPPER('&&owner')) from dual;10spool off;11 12UNDEFINE table_name owner13set heading on;

Save it as ora-get-ddl.sql and run it with SQL> @ora-get-ddl.

Open in denrepo

Helps with

More Oracle scripts: Objects & schema