0

How can I get the create table command which is used to create a table in oracle 11g so that I can copy the command and run it in another database? Please help.

1
  • Do you have PLSQL Developer? Which tools do you have to work? Commented Jan 9, 2014 at 11:05

3 Answers 3

3
select dbms_metadata.get_ddl('TABLE', 'YOUR_TABLE_NAME_GOES_HERE')
from dual;
Sign up to request clarification or add additional context in comments.

1 Comment

This query worked. you saved me from a 4 hour search.
1

Try to spool the output of the below query,

SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
     FROM USER_TABLES u;

Like,

set pagesize 0
set long 90000
set feedback off
set echo off 

spool schema.sql 

SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
     FROM USER_TABLES u WHERE TABLE_NAME = '<your_table>';

spool off;

Reference: http://www.dba-oracle.com/oracle_tips_dbms_metadata.htm

Comments

1

Please use the below Query

select dbms_metadata.get_ddl('TABLE','YOUR_TABLE_NAME','YOUR_SCHEMA_NAME') from dual;

if you use SQL Developer, select the table name , and right click to choose Open Declaration and then Click SQL tab on the window that opens!

enter image description here

1 Comment

nice info to add to this question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.