【Oracle字典表】直接获取某表的建表语句
【核心语句】
select dbms_metadata.get_ddl('TABLE',upper('your tablename')) from dual
【实验】
建表:
create table emp91( id int, name nvarchar2(20), title varchar2(20), age number(3), salary number(8,2), primary key(id) );
取建表语句SQL:
select dbms_lob.substr(dbms_metadata.get_ddl('TABLE',upper('emp91'))) from dual
执行情况:
SQL> select dbms_lob.substr(dbms_metadata.get_ddl('TABLE',upper('emp91'))) from dual; CREATE TABLE "C##LUNA"."EMP91" ( "ID" NUMBER(*,0), "NAME" NVARCHAR2(20), "TITLE" VARCHAR2(20), "AGE" NUMBER(3,0), "SALARY" NUMBER(8,2), PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 TABLESPACE "USERS" ENABLE ) SEGMENT CREATION DEFERRED PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "USERS"
看结果还真是八九不离十,没想到Oracle还有这么一手。
参考资料:https://www.cnblogs.com/wdw31210/p/4242283.html
END