2013-03-08 12:31259人阅读评论(0)收藏举报
语法:
DBMS_METADATA.GET_DDL (
object_type IN VARCHAR2,
name IN VARCHAR2,
schema IN VARCHAR2 DEFAULT NULL,
version IN VARCHAR2 DEFAULT 'COMPATIBLE',
model IN VARCHAR2 DEFAULT 'ORACLE',
transform IN VARCHAR2 DEFAULT 'DDL')
RETURN CLOB;
示例:select dbms_metadata.get_ddl('TABLE','EMP','SCOTT') from dual;
-
SQL> select dbms_metadata.get_ddl('TABLE','EMP','SCOTT') from dual;
-
DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
-
--------------------------------------------------------------------------------
-
CREATETABLE"SCOTT"."EMP"
-
( "EMPNO" NUMBER(4,0),
-
"ENAME" VARCHAR2(10),
-
--设置LONG和pagesize后能完全显示
-
SQL> SET LONG 2000000
-
SQL> SET PAGESIZE 0
-
SQL> select dbms_metadata.get_ddl('TABLE','EMP','SCOTT') from dual;
-
CREATETABLE"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"PRIMARYKEY ("EMPNO")
-
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
-
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"FOREIGNKEY ("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
-
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
-
TABLESPACE "USERS"
本文转自东方之子736651CTO博客,原文链接: http://blog.51cto.com/ecloud/1266226,如需转载请自行联系原作者