PAVITRA
PAVITRA

Reputation: 861

Generate table creation scripts from Oracle Database 11g

A table in Oracle Database 11g contains the sequences and triggers if we are to use auto-increment fields.
I'm using the Oracle SQL Developer and couldn't find a solid way to create a consolidated table creation script.
Is it possible to create a consolidated DDL script with the below artefacts for a given table :

  1. Table creation
  2. Sequences
  3. Triggers
  4. Foreign keys
  5. Primary keys

Upvotes: 0

Views: 497

Answers (1)

Littlefoot
Littlefoot

Reputation: 142720

It is the DBMS_METADATA built-in package we use for such a purpose and its GET_DDL function.

More info in documentation.

Quite a few examples on Oracle-base site (scroll down, to the bottom of the page).

For a single table (which is what you asked), you'd run e.g.

select dbms_metadata.get_ddl('TABLE', 'EMP', 'SCOTT') from dual;

Upvotes: 1

Related Questions