简体   繁体   中英

Getting the create table command used in oracle 11g

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.

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

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

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!

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM