METADATADDL and stored procedures can be readily displayed from the data dictionary using the dbms_metadata function. You can punch individual objects or an entire Oracle schema with this potent tool. Its ease of usage is its best feature. Oracle will extract ready-to-use DDL if you simply execute dbms_metadata.get_ddl, supply the object names, and hit enter. STEP : 1 : To get the Table structure from the metadataselect dbms_metadata.get_ddl('TABLE','EMP','SCOTT') from dual; DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') -------------------------------------------------------------------------------- CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10), SQL> set long 5000; SQL> / DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') -------------------------------------------------------------------------------- CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "MGR" NUMBER(4,0), "HIREDATE" DATE, "SAL" NUMBER(7,2), "COMM" NUMBER(7,2), "DEPTNO" NUMBER(2,0), CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') -------------------------------------------------------------------------------- USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE, CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO") REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') -------------------------------------------------------------------------------- PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ☛ Join to Learn from Experts: Oracle SQL Training in Chennai by TesDBAcademy
« Previous
Next Topic »
(SQL - DBMS ERROR LOG)
|