Chinaunix首页 | 论坛 | 博客
  • 博客访问: 194576
  • 博文数量: 19
  • 博客积分: 1865
  • 博客等级: 上尉
  • 技术积分: 640
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-06 10:34
文章分类

全部博文(19)

文章存档

2012年(19)

我的朋友

分类: Oracle

2012-08-09 14:36:13

  1. 1.显示设置:
  2.   
  3. /*
  4.  * 创建DBMS_METADATA:$ORACLE_HOME/rdbms/admin/catmeta.sql
  5.  */
  6. SET SERVEROUTPUT ON
  7. SET LINESIZE 1000
  8. SET FEEDBACK OFF
  9. SET long 999999
  10. SET PAGESIZE 1000
  11. /*
  12.  * 若希望不显示storage参数:
  13.  * EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
  14.  */
  15.    
  16. 2.9i R2所支持的45个OBJECT TYPE:
  17.  TypeName Meaning
  18. ------------------------------ ------------------------------
  19. AUDIT_OBJ auditsofschemaobjects
  20. AUDIT auditsofSQLstatements
  21. ASSOCIATION associatestatistics
  22. CLUSTER clusters
  23. COMMENT comments
  24. CONSTRAINT constraints
  25. CONTEXT applicationcontexts
  26. DB_LINK databaselinks
  27. DEFAULT_ROLE defaultroles
  28. DIMENSION dimensions
  29. DIRECTORY directories
  30. FUNCTION storedfunctions
  31. INDEX indexes
  32. INDEXTYPE indextypes
  33. JAVA_SOURCE Javasources
  34. LIBRARY externalprocedurelibraries
  35. MATERIALIZED_VIEW materializedviews
  36. MATERIALIZED_VIEW_LOG materializedviewlogs
  37. OBJECT_GRANT objectgrants
  38. OPERATOR operators
  39. OUTLINE storedoutlines
  40. PACKAGE storedpackages
  41. PACKAGE_SPEC packagespecifications
  42. PACKAGE_BODY packagebodies
  43. PROCEDURE storedprocedures
  44. PROFILE profiles
  45. PROXY proxyauthentications
  46. REF_CONSTRAINT referentialconstraint
  47. ROLE roles
  48. ROLE_GRANT rolegrants
  49. ROLLBACK_SEGMENT rollbacksegments
  50. SEQUENCE sequences
  51. SYNONYM synonyms
  52. SYSTEM_GRANT systemprivilegegrants
  53. TABLE tables
  54. TABLESPACE tablespaces
  55. TABLESPACE_QUOTA tablespacequotas
  56. TRIGGER triggers
  57. TRUSTED_DB_LINK trustedlinks
  58. TYPE user-definedtypes
  59. TYPE_SPEC typespecifications
  60. TYPE_BODY typebodies
  61. USER users
  62. VIEW views
  63. XMLSCHEMA XMLschema
  64. 3.举例:
  65.   
  66. --表:(注意:表名要大写)

  67. SQL>SELECTDBMS_METADATA.GET_DDL('TABLE','T2')FROMDUAL;
  68.    
  69. DBMS_METADATA.GET_DDL('TABLE','T2')
  70. --------------------------------------------------------------------------------
  71. CREATETABLE"TEST"."T2"
  72.   ( "OWNER"VARCHAR2(30),
  73.         "OBJECT_NAME"VARCHAR2(128),
  74.         "SUBOBJECT_NAME"VARCHAR2(30),
  75.         "OBJECT_ID"NUMBER,
  76.         "DATA_OBJECT_ID"NUMBER,
  77.         "OBJECT_TYPE"VARCHAR2(18),
  78.         "CREATED"DATE,
  79.         "LAST_DDL_TIME"DATE,
  80.         "TIMESTAMP"VARCHAR2(19),
  81.         "STATUS"VARCHAR2(7),
  82.         "TEMPORARY"VARCHAR2(1),
  83.         "GENERATED"VARCHAR2(1),
  84.         "SECONDARY"VARCHAR2(1)
  85.   )PCTFREE10PCTUSED40INITRANS1MAXTRANS255NOCOMPRESSLOGGING
  86.  STORAGE(INITIAL65536NEXT1048576MINEXTENTS1MAXEXTENTS2147483645
  87.  PCTINCREASE0FREELISTS1FREELISTGROUPS1BUFFER_POOLDEFAULT)
  88.  TABLESPACE"EXAMPLE"
  89.    
  90. --索引:
  91. SQL>SELECTDBMS_METADATA.GET_DDL('INDEX','IDX_OBJECT_NAME')FROMDUAL;
  92.    
  93. DBMS_METADATA.GET_DDL('INDEX','IDX_OBJECT_NAME')
  94. --------------------------------------------------------------------------------

  95.  CREATEINDEX"TEST"."IDX_OBJECT_NAME"ON"TEST"."T2"("OBJECT_NAME")
  96.  PCTFREE10INITRANS2MAXTRANS255
  97.  STORAGE(INITIAL65536NEXT1048576MINEXTENTS1MAXEXTENTS2147483645
  98.  PCTINCREASE0FREELISTS1FREELISTGROUPS1BUFFER_POOLDEFAULT)
  99.  TABLESPACE"EXAMPLE"
  100.    
  101. --主键:
  102. SQL>SELECTDBMS_METADATA.GET_DDL('CONSTRAINT','PK_AA')FROMDUAL;
  103.    
  104. DBMS_METADATA.GET_DDL('CONSTRAINT','PK_AA')
  105. --------------------------------------------------------------------------------
  106.   
  107.  ALTERTABLE"TEST"."PARENT"ADDCONSTRAINT"PK_AA"PRIMARYKEY("BB")
  108.  USINGINDEXPCTFREE10INITRANS2MAXTRANS255
  109.  STORAGE(INITIAL65536NEXT1048576MINEXTENTS1MAXEXTENTS2147483645
  110.  PCTINCREASE0FREELISTS1FREELISTGROUPS1BUFFER_POOLDEFAULT)
  111.  TABLESPACE"EXAMPLE" ENABLE
  112.    
  113. --外键:
  114. SQL>SELECTDBMS_METADATA.GET_DDL('REF_CONSTRAINT','FK_AA')FROMDUAL;
  115.    
  116. DBMS_METADATA.GET_DDL('REF_CONSTRAINT','FK_AA')
  117. --------------------------------------------------------------------------------
  118.    
  119.  ALTERTABLE"TEST"."CHILD"ADDCONSTRAINT"FK_AA"FOREIGNKEY("AA")
  120.           REFERENCES"TEST"."PARENT"("BB")ENABLE
  121.       
  122. --表空间:
  123.  SQL> SELECT DBMS_METADATA.GET_DDL('TABLESPACE','SYSAUX') FROM DUAL;
  124. DBMS_METADATA.GET_DDL('TABLESPACE','SYSAUX')
  125. ------------------------------------------------------------------------

  126.   
  127.   CREATE TABLESPACE "SYSAUX" DATAFILE
  128.   '/u01/oracle/oradata/orcl/sysaux01.dbf
  129.   
  130. --用户:
  131. DBMS_METADATA.GET_DDL('USER','SYSTEM')
  132. -------------------------------------------------------------------------------
  133.   
  134.    ALTER USER "SYSTEM" IDENTIFIED BY VALUES 'S:C27C11320D7002613C610B3F5C293AE8
  135.    
  136. 4.综上所述:select dbms_metadata.get_ddl(’OBJECT_TYPE’,'OBJECT_NAME’,'SCHEMA’) from dual|user_xxx|all_xxx|dba_xxx;





 

阅读(1375) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:VERITAS 配置

给主人留下些什么吧!~~