zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Qt快速入门学习笔记(基础篇)
    IDEA 创建文件夹总默认根节点问题解决
    SpringBoot 集成MyBatis 中的@MapperScan注解
    Springboot项目下mybatis报错:Invalid bound statement (not found)
    IDEA maven项目查自动查看依赖关系,解决包冲突问题
    Mybatis-generator/通用Mapper/Mybatis-Plus对比
    Mybatis
    在一个已经使用mybatis的项目里引入mybatis-plus,结果不能共存
    springboot整合图像数据库Neo4j
    Spring Boot:Boot2.0版本整合Neo4j
  • 原文地址:https://www.cnblogs.com/kawashibara/p/10054678.html
Copyright © 2011-2022 走看看