0

我正在使用 dbms_metadata.set_transform_param 包为表导出 ddl 语句。这按预期工作。但是,我也有兴趣从输出中删除某些行。

例如:这是其中一张表的输出:

CREATE TABLE "FREEZES" 
   (    "PLAYER_ID" NUMBER(9,0) NOT NULL ENABLE, 
    "PRODUCT_ID" NUMBER(19,0)
   )   
  TABLESPACE "MINE" ;
  ALTER TABLE "FREEZES" ADD CONSTRAINT "FREEZES_U" UNIQUE ("PLAYER_ID", "PRODUCT_ID")
  USING INDEX   
  TABLESPACE "MINE_IDX"  ENABLE;
  ALTER TABLE "FREEZES" ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
  ALTER TABLE "FREEZES" ADD SUPPLEMENTAL LOG DATA (FOREIGN KEY) COLUMNS;
  ALTER TABLE "FREEZES" ADD SUPPLEMENTAL LOG DATA (UNIQUE INDEX) COLUMNS;
  ALTER TABLE "FREEZES" ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

我想要的是:

CREATE TABLE "FREEZES" 
   (    "PLAYER_ID" NUMBER(9,0) NOT NULL ENABLE, 
    "PRODUCT_ID" NUMBER(19,0)
   )   
  TABLESPACE "MINE" ;
  ALTER TABLE "FREEZES" ADD CONSTRAINT "FREEZES_U" UNIQUE ("PLAYER_ID", "PRODUCT_ID")
  USING INDEX   
  TABLESPACE "MINE_IDX"  ENABLE;

这是我正在使用的查询:

SELECT dbms_metadata.get_ddl(object_type, object_name, owner) as object_ddl
from dba_objects where owner = 'MINE' and object_type = 'TABLE';

我确实知道我必须使用正则表达式,例如:

SELECT regexp_replace(dbms_metadata.get_ddl(object_type, object_name, owner), 'pattren') as object_ddl
    from dba_objects where owner = 'MINE' and object_type = 'TABLE';
4

0 回答 0