DBMS_METADATA.GET_DDL

on

Learned a real cool dbms procedure today: dbms_metadata.get_ddl

when used it will return te complete create statement of given database object

for example:

select dbms_metadata.get_ddl('TABLE','SAM_LOGGING') from dual

will result in:

DBMS_METADATA.GET_DDL(‘TABLE’,’SAM_LOGGING’)
——————————————————————————–

CREATE TABLE “XXX”.”SAM_LOGGING”
( “LOG_ID” NUMBER,
“CNV_CODE” CHAR(4),
“KEY_” VARCHAR2(4000),
“MESSAGE” VARCHAR2(4000),
“TIMESTAMP” DATE,
“LOG_TYPE” VARCHAR2(20),
“RUN_ID” NUMBER
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 125829120 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE “YYY”

1 row selected.