關於dbms_metadata.get_ddl的認識

zangqianglei發表於2015-05-15

  SQL> select dbms_metadata.get_ddl('TABLESPACE','TEST') from dual;

    CREATE TABLESPACE "TEST" DATAFILE

    '/home/oracle/TEST/TEST.dbf' SIZE 52428800

    LOGGING ONLINE PERMANENT BLOCKSIZE 8192

    EXTENT MANAGEMENT LOCAL TESTALLOCATE SEGMENT SPACE MANAGEMENT MANUAL

    ALTER DATABASE DATAFILE

    '/home/oracle/TEST/TEST.dbf' RESIZE 2097152000

    檢視建立使用者語句

    SQL> select dbms_metadata.get_ddl('USER','TEST') from dual;

    CREATE USER "TEST" IDENTIFIED BY VALUES '90CEB80324B4BC3D'

    DEFAULT TABLESPACE "TEST"

    TEMPORARY TABLESPACE "TEMP"

    檢視一個使用者的授權相關資訊

    SQL>  SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT','TEST') from dual;

    GRANT "CONNECT" TO "TEST"

    GRANT "RESOURCE" TO "TEST"

    SQL> SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','TEST') from dual;

    GRANT CREATE ANY SYNONYM TO "TEST"

    GRANT CREATE SYNONYM TO "TEST"

    GRANT SELECT ANY TABLE TO "TEST"

    GRANT LOCK ANY TABLE TO "TEST"

    GRANT DROP ANY TABLE TO "TEST"

    GRANT ALTER ANY TABLE TO "TEST"


主要是用於查詢一些物件的建立語句。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25954236/viewspace-1656113/,如需轉載,請註明出處,否則將追究法律責任。

相關文章