我们一般使用dbms_metadata.get_ddl获取对象的ddl的时候,有时会获取一些其它额外的信息,比如当你想获取表的创建语句的时候,你会得到表的约束信息,这个信息可能是你不想要的,那么就能够用SESSION_TRANSFORM对它进行过滤。

看以下的演示样例,创建一个有主键和外键的表,获取他的ddl语句:

SQL> CREATE TABLE tb1 (id int primary key);

Table created.

SQL> create table tb2 (id int primary key references tb1(id));

Table created.
SQL> insert into tb1 values(1); 1 row created. SQL> commit; Commit complete. SQL> insert into tb2 values(1); 1 row created. SQL> commit; SQL> select dbms_metadata.get_ddl('TABLE','TB2','TEST') from dual; DBMS_METADATA.GET_DDL('TABLE','TB2','TEST')
-------------------------------------------------------------------------------- CREATE TABLE "TEST"."TB2"
( "ID" NUMBER(*,0),
PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ENABLE,
FOREIGN KEY ("ID")
REFERENCES "TEST"."TB1" ("ID") 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 DE
FAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"

不单单是获取到了创建的基本字段的语句。还有主键,约束。外键。存储參数。表空间等,假设这些你不须要,都是能够进行过滤的,比如我过滤掉主键、外键、存储信息

使用例如以下语句:

exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',false);

exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',false);

exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);


exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',false);

PL/SQL procedure successfully completed.

exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',false);

PL/SQL procedure successfully completed.

SQL> exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);

PL/SQL procedure successfully completed.

SQL>
SQL> select dbms_metadata.get_ddl('TABLE','TB2','TEST') from dual; DBMS_METADATA.GET_DDL('TABLE','TB2','TEST')
-------------------------------------------------------------------------------- CREATE TABLE "TEST"."TB2"
( "ID" NUMBER(*,0)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS"

还能够对其它的一些信息做过滤,表格例如以下:

Table 87-22 SET_TRANSFORM_PARAM: Transform Parameters for the DDLTransform

Object Type

Name

Datatype

Meaning

All objects

PRETTY

BOOLEAN

If TRUE, format the output with indentation and line feeds. Defaults toTRUE.

All objects

SQLTERMINATOR

BOOLEAN

If TRUE, append a SQL terminator (; or /)
to each DDL statement. Defaults to FALSE.

TABLE

SEGMENT_ATTRIBUTES

BOOLEAN

If TRUE, include segment attributes clauses in the DDL. If FALSE, omit them.
Defaults to TRUE.

TABLE

STORAGE

BOOLEAN

If TRUE, include storage clauses in the DDL. If FALSE, omit them. Defaults
to TRUE. (Ignored if SEGMENT_ATTRIBUTES is FALSE.)

TABLE

TABLESPACE

BOOLEAN

If TRUE, include tablespace clauses in the DDL. If FALSE, omit them. (Ignored
if SEGMENT_ATTRIBUTES is FALSE.) Defaults to TRUE.

TABLE

CONSTRAINTS

BOOLEAN

If TRUE, include all non-referential table constraints in the DDL. If FALSE,
omit them. Defaults to TRUE.

TABLE

REF_CONSTRAINTS

BOOLEAN

If TRUE, include all referential constraints (foreign keys) in the DDL. IfFALSE,
omit them. Defaults to TRUE.

TABLE

CONSTRAINTS_AS_ALTER

BOOLEAN

If TRUE, include table constraints as separate ALTER TABLE (and, if necessary, CREATE
INDEX) statements. If FALSE, specify table constraints as part of the CREATE TABLE statement.
Defaults to FALSE. Requires thatCONSTRAINTS be TRUE.

TABLE

OID

BOOLEAN

If TRUE, include the OID clause for object tables in the DDL. If FALSE, omit
it. Defaults to FALSE.

TABLE

SIZE_BYTE_KEYWORD

BOOLEAN

If TRUE, include the BYTE keyword as part of the size specification ofCHAR and VARCHAR2 columns
that use byte semantics. If FALSE, omit the keyword. Defaults to FALSE.

TABLE, INDEX

PARTITIONING

BOOLEAN

If TRUE, include partitioning clauses in the DDL. If FALSE, omit them. Defaults
to TRUE.

INDEX, CONSTRAINT,ROLLBACK_SEGMENT,CLUSTER, TABLESPACE

SEGMENT_ATTRIBUTES

BOOLEAN

If TRUE, include segment attributes clauses (physical attributes, storage attributes, tablespace, logging) in the DDL. If FALSE,
omit them. Defaults to TRUE.

INDEX, CONSTRAINT,ROLLBACK_SEGMENT, CLUSTER

STORAGE

BOOLEAN

If TRUE, include storage clauses in the DDL. If FALSE, omit them. (Ignored
if SEGMENT_ATTRIBUTES is FALSE.) Defaults to TRUE.

INDEX, CONSTRAINT,ROLLBACK_SEGMENT, CLUSTER

TABLESPACE

BOOLEAN

If TRUE, include tablespace clauses in the DDL. If FALSE, omit them. (Ignored
if SEGMENT_ATTRIBUTES is FALSE.) Defaults to TRUE.

TYPE

SPECIFICATION

BOOLEAN

If TRUE, include the type specification in the DDL. If FALSE, omit it. Defaults
to TRUE.

TYPE

BODY

BOOLEAN

If TRUE, include the type body in the DDL. If FALSE, omit it. Defaults toTRUE.

TYPE

OID

BOOLEAN

If TRUE, include the OID clause in the DDL. If FALSE, omit it. Defaults toFALSE.

PACKAGE

SPECIFICATION

BOOLEAN

If TRUE, include the package specification in the DDL. If FALSE, omit it.
Defaults to TRUE.

PACKAGE

BODY

BOOLEAN

If TRUE, include the package body in the DDL. If FALSE, omit it. Defaults
to TRUE.

VIEW

FORCE

BOOLEAN

If TRUE, use the FORCE keyword in the CREATE
VIEW statement. If FALSE, do not use the FORCE keyword in the CREATE
VIEW statement. Defaults toTRUE.

OUTLINE

INSERT

BOOLEAN

If TRUE, include the INSERT statements into the OL$ dictionary tables that
will create the outline and its hints. If FALSE, omit a CREATE OUTLINEstatement.
Defaults to FALSE.

Note: This object type is being deprecated.

All objects

DEFAULT

BOOLEAN

Calling SET_TRANSFORM_PARAM with this parameter set to TRUE has the effect
of resetting all parameters for the transform to their default values. Setting this FALSE has no effect. There is no default.

All objects

INHERIT

BOOLEAN

If TRUE, inherits session-level parameters. Defaults to FALSE. If an application
calls ADD_TRANSFORM to add the DDL transform, then by default the only transform parameters that apply are those explicitly set for that transform handle. This has no effect if the transform
handle is the session transform handle.

ROLE

REVOKE_FROM

Text

The name of a user from whom the role must be revoked. If this is a non-null string and if the CREATE ROLE statement
grants you the role, aREVOKE statement is included in the DDL after the CREATE ROLEstatement.

Note: When you issue a CREATE ROLE statement, Oracle may grant you the role.
You can use this transform parameter to undo the grant.

Defaults to null string.

TABLESPACE

REUSE

BOOLEAN

If TRUE, include the REUSE parameter for datafiles in a tablespace to indicate
that existing files can be reused. If FALSE, omit the REUSEparameter.

Defaults to FALSE.

CLUSTER, INDEX,ROLLBACK_SEGMENT, TABLE,TABLESPACE

PCTSPACE

NUMBER

A number representing the percentage by which space allocation for the object type is to be modified. The value is the number of one-hundreths of the current allocation. For example, 100 means 100%.

If the object type is TABLESPACE, the following size values are affected:

- in file specifications, the value of SIZE

- MINIMUM EXTENT

- EXTENT MANAGEMENT LOCAL UNIFORM SIZE

For other object types, INITIAL and NEXT are affected.

DBMS_METADATA中使用SESSION_TRANSFORM过滤不想获取的DDL的更多相关文章

  1. jmeter提取正则表达式中所有关联值-----我想获取所有的ID

    [{ "ID": 1, "Name": "张三" }, { "ID": 2, "Name": &qu ...

  2. Mybatis 在 insert 之后想获取自增的主键 id

    记录一次傻逼的问题, 自己把自己蠢哭:Mybatis 在 insert 之后想获取自增的主键 id,但却总是返回1 错误说明: 返回的1是影响的行数,并不是自增的主键id: 想要获取自增主键id,需要 ...

  3. 微信小程序——picker通过value返回你想获取的值

    关于微信小程序中的picker使用方法可以访问:picker-小程序 从它的官方文档中,可以看出它返回的value值是它range的下标: 在项目中,我们大多数时候传的值并不是需要这个下标,而是其他的 ...

  4. 如何在K3 WISE BOS集成开发工具中自定义字段过滤条件

    1.结论 对于输入过滤条件后BOS报“列名不正确”的过滤条件,要在列名前增加x2标识 无效的过滤 FNumber ,,,,,) 正确的过滤 x2.FNumber ,,,,,) 2.完全可以不看的探索过 ...

  5. Mybatis 在 insert 之后想获取自增的主键 id,但却总是返回1

    记录一次傻逼的问题, 自己把自己蠢哭:Mybatis 在 insert 之后想获取自增的主键 id,但却总是返回1 错误说明: 返回的1是影响的行数,并不是自增的主键id: 想要获取自增主键id,需要 ...

  6. 代码中,使用__DATE__宏,获取程序编译时间,如何保证每次编译代码(非重新生成方式),都能更新__DATE__的值?

    代码中,使用__DATE__宏,获取程序编译时间,如何保证每次编译代码(非重新生成方式),都能更新__DATE__的值? 解决:通过vs的预先生成命令中,添加批处理命令,删除对应的obj文件方式,强制 ...

  7. javascript中无法通过div.style.left获取值的问题

    一.问题总结: 样式必须直接写在元素内部才能通过div.style.left直接获取属性值(也就是必须是内联样式才行),定义在css中的样式不能通过这种方式获取. 让元素移动到200停止 setTim ...

  8. Selenium2学习-036-WebUI自动化实战实例-034-JavaScript 在 Selenium 自动化中的应用实例之六(获取 JS 执行结果返回值)

    Selenium 获取 JavaScript 返回值非常简单,只需要在 js 脚本中将需要返回的数据 return 就可以,然后通过方法返回 js 的执行结果,方法源码如下所示: /** * Get ...

  9. Selenium2学习-031-WebUI自动化实战实例-029-JavaScript 在 Selenium 自动化中的应用实例之四(获取元素位置和大小)

    通过 JS 或 JQuery 获取到元素后,通过 offsetLeft.offsetTop.offsetWidth.offsetHeight 即可获得元素的位置和大小,非常的简单,直接上源码了,敬请参 ...

随机推荐

  1. bzoj4144 [AMPPZ2014]Petrol

    link 题意: 给一个n个点m条边的带权无向图,其中k个点是加油站,每个加油站可以加满油,但不能超过车的油量上限.有q个询问,每次给出x,y,b,保证x,y都是加油站,问一辆油量上限为b的车从x出发 ...

  2. Redis 锁的实现方案

    开发中不可避免的是碰到并发请求,在数据严谨性的要求不高时,我们也不需要做什么处理,但如果碰到数据严谨性非常高的时候(例如:用户金额,秒杀产品的库存...),我们就需要慎重处理了. 解决方案多种多样,下 ...

  3. vagrant 常用命令以及常用操作

    列出这些命令,主要是防止脑内存不足.目前这些命令是我常用的,以后其他命令用的多,我再继续添加... 分享些本人用的百度网盘box,国外的太坑... 本人分享的百度网盘:http://pan.baidu ...

  4. HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)

    Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  5. Spring发送带附件邮件

    下面是一个例子使用Spring通过Gmail SMTP服务器来发送电子邮件附件.为了包含附件的电子邮件,你必须使用 Spring的JavaMailSender及MimeMessage 来代替 Mail ...

  6. 用 C# 做人脸检测(基于EmguCV)

    c#datagridmatlab人脸识别图像处理path 下载源码 准备工作(必须) 下载  EmguCV 傻瓜安装后,把 bin 目录添加到环境变量里去,比如安装在 X:\EmguCV\ 目录下,就 ...

  7. SpringMVC 理论与有用技术(一) 简单、有用、易懂的几个实例

    SpringMVC先来看一下百度百科中的定义; Spring MVC属于SpringFrameWork的兴许产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应 ...

  8. 扩展LVM 逻辑卷存储空间

    原因: 运行在Xen DomU的磁盘空间不足,需要扩展.DomU的存储主要为[os镜像文件+lv逻辑卷]的形式,现要对逻辑卷进行扩展. 过程(离线方式): 卸载逻辑卷 umount /dev/VolG ...

  9. 【redis】spring boot中 使用redis hash 操作 --- 之 使用redis实现库存的并发有序操作

    示例: @Autowired StringRedisTemplate redisTemplate; @Override public void dealRedis(Dealer dealer) { d ...

  10. Apache下error.log文件太大的处理

    偶尔发现Apache下的错误日志非常的大,有4G多,先停止Apache服务的所有进程,最简单就是输命令:net stop apache2.2,然后删除 Apache2/logs/目录下的 error. ...