• DBMS_METADATA.set_transform_param格式化输出


    DBMS_METADATA.set_transform_param格式化输出获得DDL

    --输出信息采用缩排或换行格式化

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'PRETTY', TRUE);

    --确保每个语句都带分号

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'SQLTERMINATOR', TRUE);

    --关闭表索引、外键等关联(后面单独生成)

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'CONSTRAINTS', FALSE);

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'REF_CONSTRAINTS', FALSE);

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'CONSTRAINTS_AS_ALTER', FALSE);

    --关闭存储、表空间属性

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'STORAGE', FALSE);

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'TABLESPACE', FALSE);

    --关闭创建表的PCTFREE、NOCOMPRESS等属性

    EXEC DBMS_METADATA.set_transform_param(DBMS_METADATA.session_transform, 'SEGMENT_ATTRIBUTES', FALSE);

    18.11.1 Using a PL/SQL Package to Display Information About Schema Objects

    The Oracle-supplied PL/SQL package procedure DBMS_METADATA.GET_DDL lets you obtain metadata (in the form of DDL used to create the object) about a schema object.

    See Also:

    Oracle Database PL/SQL Packages and Types Reference for a description of the DBMS_METADATA package

    Example: Using the DBMS_METADATA Package

    The DBMS_METADATA package is a powerful tool for obtaining the complete definition of a schema object. It enables you to obtain all of the attributes of an object in one pass. The object is described as DDL that can be used to (re)create it.

    In the following statements the GET_DDL function is used to fetch the DDL for all tables in the current schema, filtering out nested tables and overflow segments. The SET_TRANSFORM_PARAM (with the handle value equal to DBMS_METADATA.SESSION_TRANSFORM meaning "for the current session") is used to specify that storage clauses are not to be returned in the SQL DDL. Afterwards, the session-level transform parameters are reset to their defaults. Once set, transform parameter values remain in effect until specifically reset to their defaults.

    EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM( DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false); SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_ALL_TABLES u WHERE u.nested='NO' AND (u.iot_type is null or u.iot_type='IOT'); EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM( DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');

    The output from DBMS_METADATA.GET_DDL is a LONG data type. When using SQL*Plus, your output may be truncated by default. Issue the following SQL*Plus command before issuing the DBMS_METADATA.GET_DDL statement to ensure that your output is not truncated:

    SQL> SET LONG 9999

  • 相关阅读:
    通过 nginx 搭建一个基于 httpflv 的直播流媒体服务器
    obs+nodemediaserver+flv.js搭建直播流媒体服务器
    跨平台跨架构的统信DTK开发套件教程及常见问题
    如何获取youtube视频的高清封面?
    Flutter路由配置
    调用feign接口新增用户报错xxx is not a type supported by this encoder
    C# 程序动态调用 C/C++ 动态库函数
    ELK部署
    ElasticSearch的常用API
    Microsoft IIS Web服务器配置优化
  • 原文地址:https://www.cnblogs.com/kawashibara/p/10054678.html
Copyright © 2020-2023  润新知