Dbms_metadata package

hello experts,
there is an error while using above package
SQL> ED
Wrote file afiedt.buf
1* select dbms_metadata.get_ddl( 'TABLE', 'T1' ) from dual
SQL> /
select dbms_metadata.get_ddl( 'TABLE', 'T1' ) from dual
ERROR at line 1:
ORA-01024: invalid datatype in OCI call
thanks
yash

it works for me.
  1* select dbms_metadata.get_ddl( 'TABLE','INSANE') from dual
SQL> /
DBMS_METADATA.GET_DDL('TABLE','INSANE')
  CREATE TABLE "USER1"."INSANE"
   (     "DEPT" NUMBER NOT NULL ENABLE,
     "FIRSTNAME" VARCHAR2(30),
     "SURNAME" VARCHAR2(30),
     "CITY" VARCHAR2(30),
     "FIRSTNAME2" VARCHAR2(30),
     "SURNAME2" VARCHAR2(30),
     "CITY2" VARCHAR2(30),
     "FIRSTNAME3" VARCHAR2(30),
     "SURNAME3" VARCHAR2(30),
DBMS_METADATA.GET_DDL('TABLE','INSANE')
     "CITY3" VARCHAR2(30)
   ) 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"
SQL>

Similar Messages

  • DBMS_Metadata package wrapping lines

    How can you set the line size for the DDL that is generated from the DBMS_MetaData pkg? If I try to run the script that is generated by this output, I get errors because things are wrapped.
    I used this sql to generate my ddl:
    select dbms_metadata.get_ddl('TABLE','EMP') FROM DUAL;
    Anybody have a good idea on how to get this output to work properly?
    Thanks,
    Jim

    Setting LONG does not help wrapping lines, use LINESIZE and COLUMN FORMAT.
    I am using this script:
    PROMPT exporting &1. &2..&3.
    --##&1=OBJECT_TYPE &2=OWNER &3=OBJECT_NAME
    set echo off
    set linesize 1000
    set long 65536
    set trimspool on
    set null null
    set head off
    set pagesize 0
    set newpage none
    set headsep off
    set feedback off
    set ver off
    set pause off
    set flush off
    column aaa format a1000
    EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
    spool &Your_package.sql
    select dbms_metadata.get_ddl('PACKAGE', '&Your_package', '&OWNER') aaa from dual
    spool off

  • DBMS_METADATA package issue

    All,
    When I use the DBMS_METADATA.GET_DDL('INDEX',indexnm) package, I am getting the entire DB spcecifications as follows
    CREATE INDEX "T_OD"."XIE3OD_ORDER" ON "T_OD"."OD_ORDER" ("ORD_MNT_DTM")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "OD_DATA01"
    1) Is there a way to avoid the storage values? I only need CREATE INDEX "T_OD"."XIE3OD_ORDER" ON "T_OD"."OD_ORDER" ("ORD_MNT_DTM")
    2) Will "COMPUTE STATISTICS" compute stats on table also?
    Thanks,
    Saff

    Hi,
    For your table not existing error it could be
    1) Table not existing
    or
    2) Nonprivileged users can see the metadata of only their own objects.
    SYS and users with SELECT_CATALOG_ROLE can see all objects
    For other problem, there is a bug reported for your version, can search in metalink for workaround
    Regards

  • DBMS_METADATA Package Body won't compile

    I get a PLS-00103 error when attempting to complile the package body for SYS.DBMS_METADATA. The body hasn't been modified so I'm not sure where to look.

    Or,
    Does anyone know where in a script I can find the line that created this package and body in the first place?

  • Some help with dbms_metadata package

    Hi
    I starting to use the package DBMS_Metadata for return metadata and I have some questions
    Firts
    I have a table TBMETADATA (subject varchar2, result clob)
    object = 'table', 'procedure', etc.
    result = keep output dbms_metadata.get_dll
    Now if I drop a table x from my database. How can I to run the script for this table x, stored in TBMETADATA.
    Any idea

    hi user,
    try with this,
       select a from
        select dbms_lob.substr(result,4000) a  from TBMETADATA
       ) where a like '%X%'
       Since you are not saving the table name in the TBTEMPDATA table im searching the same using like operator.
    Hope this helps.
    Regards
    Sankar MN

  • Error using DBMS_METADATA package

    Hi All,
    I have the following query and trying to get the DDLs for the foreign Key constraint on tables
    SELECT   TO_CHAR (DBMS_METADATA.get_ddl ('CONSTRAINT', constraint_name))
               || ';'
        FROM   all_constraints
       WHERE   status = 'ENABLED'
               AND table_name IN
                        ('OD_MF_ACCT_PLCY')
    ORDER BY   table_name;I am getting the following error:
    ORA-31603: object "ACCTROLE_FK_ACCTPLCY" of type CONSTRAINT not found in schema "D_OD"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 2806
    ORA-06512: at "SYS.DBMS_METADATA", line 4333
    ORA-06512: at line 1
    Note able to decipher the same. Could you help me what it means?
    Thanks,
    Saff

    The table is in D_OD only.
    But I think I got the error...Was just reading about various constant types....instead of CONSTRAINT i think I need to give REF_CONSTRAINT as the type...
    This worked out
    SELECT   TO_CHAR (DBMS_METADATA.get_ddl ('REF_CONSTRAINT', constraint_name))
               || ';'
        FROM   user_constraints
       WHERE   status = 'ENABLED' AND constraint_type = 'R'
               AND table_name IN
                        ('OD_MF_ACCT_PLCY')
    ORDER BY   table_name;Thanks,
    Saff
    Edited by: saffron on Feb 1, 2010 1:19 PM

  • [RESOLVED] dbms_metadata.get_ddl() issues

    Hi all,
    I'm having a bit of an issue using the dbms_metadata package. I've never used it so possibly I'm unaware of something basic.
    I'm getting diferent results in my production and dev servers, both of which have this configuration:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    I am trying to replicate the DDL for one particular schema and so tried the following:
    SQL> select dbms_metadata.get_ddl('TABLE',u.table_name)
      2  from user_tables u
      3  where rownum = 1;
    ERROR:
    ORA-06502: PL/SQL: numeric or value error
    LPX-00210: expected '<' instead of 'n'
    ORA-06512: at "SYS.UTL_XML", line 0
    ORA-06512: at "SYS.DBMS_METADATA_INT", line 3698
    ORA-06512: at "SYS.DBMS_METADATA_INT", line 4553
    ORA-06512: at "SYS.DBMS_METADATA", line 458
    ORA-06512: at "SYS.DBMS_METADATA", line 615
    ORA-06512: at "SYS.DBMS_METADATA", line 1221
    ORA-06512: at line 1I tried again with hard-coding a table name and got these very scary results:
    SQL> select dbms_metadata.get_ddl('TABLE','CAMPAIGN_LOOKUP','XMLUSER') FROM DUAL;
    ERROR:
    ORA-06502: PL/SQL: numeric or value error
    ORA-31605: the following was returned from LpxXSLResetAllVars in routine
    kuxslResetParams:
    LPX-1: NULL pointer
    ORA-06512: at "SYS.UTL_XML", line 0
    ORA-06512: at "SYS.DBMS_METADATA_INT", line 3722
    ORA-06512: at "SYS.DBMS_METADATA_INT", line 4553
    ORA-06512: at "SYS.DBMS_METADATA", line 458
    ORA-06512: at "SYS.DBMS_METADATA", line 615
    ORA-06512: at "SYS.DBMS_METADATA", line 1221
    ORA-06512: at line 1in the above, I am logging in as the XMLUSER user and so owns the table campaign_lookup.
    Next I tried getting the DDL for another schema that while still logged in as xmluser.
    I'm certain that I have access read/write from the tclient table but got these results:
    possibly the dbms_metadata package requires you to be loged in as the schema owner though
    the oracle documentation link gives me a 404 error at the moment so I can't check.
    SQL> select dbms_metadata.get_ddl('TABLE','TCLIENT','TRAVEL') from dual;
    ERROR:
    ORA-31603: object "TCLIENT" of type TABLE not found in schema "TRAVEL"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_METADATA", line 628
    ORA-06512: at "SYS.DBMS_METADATA", line 1221
    ORA-06512: at line 1So now I log into production:
    SQL> select dbms_metadata.get_ddl('TABLE',u.table_name)
      2      from user_tables u
      3      where rownum = 1;
    DBMS_METADATA.GET_DDL('TABLE',
      CREATE TABLE "XMLUSER"."CAMPAIGN_LOOKUP"
       (    "SCHEME_ID" VARCHAR2(30),
            "S
    etc...but still can't extract DDL for another schema.
    my main issue is, I can't log into production (or our implementation environment) as the schema
    I want to extract due to big nasty DBAs locking it all down. however I can in dev, but get the above errors.
    thoughts anyone?

    Hi,
    For your table not existing error it could be
    1) Table not existing
    or
    2) Nonprivileged users can see the metadata of only their own objects.
    SYS and users with SELECT_CATALOG_ROLE can see all objects
    For other problem, there is a bug reported for your version, can search in metalink for workaround
    Regards

  • Dbms_metadata.get_ddl including comments.

    Hey all,
    Is there a way to use the dbms_metadata package to fetch the DDL of a package/function/procedure without removing the comments? For instance if you are using SQL Developer and right click a function and then click edit. The DDL for the function will appear along with the comments. This is what I would like to see.
    Any ideas?
    Cheers,
    Tyson Jouglet
    Edited by: Tyson Jouglet on Aug 27, 2009 2:29 PM

    Is there a way to use the dbms_metadata package to fetch the DDL of a package/function/procedure without removing the comments? Why do you think that the comments are removed?
    SQL>  CREATE OR REPLACE PROCEDURE p
    /* first comment*/
    AS
    -- some comments
    BEGIN
         /* some other comments*/
         NULL;
    END p;
    Procedure created.
    SQL>  SELECT dbms_metadata.get_ddl (
                    'PROCEDURE',
                    'P',
                    USER
               ) ddl
      FROM DUAL
    DDL                                                                            
      CREATE OR REPLACE PROCEDURE "MICHAEL"."P"                                    
    /* first comment*/                                                             
    AS                                                                             
    -- some comments                                                               
    BEGIN                                                                          
         /* some other comments*/                                                      
         NULL;                                                                         
    END p;                                                                         
    1 row selected.

  • Reverse engineer using DBMS_METADATA

    Hi,
    Can I use DBMS_METADATA package to reverse engineer a scheduled job from the database. I tried running below statement but it only returns the first job no matter what I do:
    select JOB,WHAT,dbms_metadata.get_ddl('JOB',USER) FROM DBA_JOBS
    I even used a where clause to make sure that I am using a specific job but the output remains same I mean I get statement generated only for first job.
    Any thought?
    Onkar

    Solomon Yakobson wrote:
    Gokhan Atil wrote:
    You may try to use DBMS_JOB.USER_EXPORT:I don't believe DBMS_JOB.USER_EXPORT is available in 9i.
    SY.Tested or guessing? Anyway, you can believe that it's available:
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE    9.2.0.8.0       Production
    TNS for Solaris: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    FUNCTION BACKGROUND_PROCESS RETURNS BOOLEAN
    PROCEDURE BROKEN
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    BROKEN                         BOOLEAN                 IN
    NEXT_DATE                      DATE                    IN     DEFAULT
    PROCEDURE CHANGE
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    WHAT                           VARCHAR2                IN
    NEXT_DATE                      DATE                    IN
    INTERVAL                       VARCHAR2                IN
    INSTANCE                       BINARY_INTEGER          IN     DEFAULT
    FORCE                          BOOLEAN                 IN     DEFAULT
    PROCEDURE INSTANCE
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    INSTANCE                       BINARY_INTEGER          IN
    FORCE                          BOOLEAN                 IN     DEFAULT
    PROCEDURE INTERVAL
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    INTERVAL                       VARCHAR2                IN
    FUNCTION IS_JOBQ RETURNS BOOLEAN
    PROCEDURE ISUBMIT
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    WHAT                           VARCHAR2                IN
    NEXT_DATE                      DATE                    IN
    INTERVAL                       VARCHAR2                IN     DEFAULT
    NO_PARSE                       BOOLEAN                 IN     DEFAULT
    PROCEDURE NEXT_DATE
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    NEXT_DATE                      DATE                    IN
    PROCEDURE REMOVE
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    PROCEDURE RUN
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    FORCE                          BOOLEAN                 IN     DEFAULT
    PROCEDURE SUBMIT
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          OUT
    WHAT                           VARCHAR2                IN
    NEXT_DATE                      DATE                    IN     DEFAULT
    INTERVAL                       VARCHAR2                IN     DEFAULT
    NO_PARSE                       BOOLEAN                 IN     DEFAULT
    INSTANCE                       BINARY_INTEGER          IN     DEFAULT
    FORCE                          BOOLEAN                 IN     DEFAULT
    PROCEDURE USER_EXPORT
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    MYCALL                         VARCHAR2                IN/OUT
    PROCEDURE USER_EXPORT
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    MYCALL                         VARCHAR2                IN/OUT
    MYINST                         VARCHAR2                IN/OUT
    PROCEDURE WHAT
    Argument Name                  Type                    In/Out Default?
    JOB                            BINARY_INTEGER          IN
    WHAT                           VARCHAR2                INRegards
    Gokhan

  • Setting DBMS_METADATA.GET_DDL Output for Materialized Views

    Hi all.
    My Oracle version is 10g.
    I'm extracting the DDL of all the objects from database using the DBMS_METADATA package. I'm using SET_TRANSFORM_PARAM to configure the output because I need a simple sql code, without information about tablespaces, storage and segment attributes. Everything works fine except when I'm working with mviews object types. I can't remove the information about tablespace, storage or segment attributes for materialized views.
    I would like to know if there's a related issue about it. Or there's something missing in my code?
    I tried to specify the object type as another parameter on DBMS_METADATA.SET_TRANSFORM_PARAM but don't work too.
    The only transform parameter that works fine with Materialized Views is the SQLTERMINATOR.
    See how I have done:
    declare
    vDDL clob;
    begin
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR',TRUE);
    select dbms_metadata.get_ddl ('MATERIALIZED_VIEW', 'MV_STO020', 'HIS117_CHECK') into vDDL FROM DUAL;
    dbms_output.put_line (vDDL);
    end;
    and how the output is:
    CREATE MATERIALIZED VIEW "HIS117_CHECK"."MV_STO020"
    ORGANIZATION HEAP 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)
    TABLESPACE "TS_HIS117"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS SELECT
    STO020_MOVEMENT_LOG_ID STO020_MOVEMENT_LOG_ID
    , STO020_QUANTITY STO020_QUANTITY
    , STO020_DATE STO020_DATE
    , STO020_BEFORE_BALANCE STO020_BEFORE_BALANCE
    , STO011_PRODUCT_MOVEMENT_ID STO011_PRODUCT_MOVEMENT_ID
    , ADM082_PRODUCT_ID ADM082_PRODUCT_ID
    , ADM089_PRODUCT_PRESENTATION_ID ADM089_PRODUCT_PRESENTATION_ID
    , STO010_MOVEMENT_TYPE_ID STO010_MOVEMENT_TYPE_ID
    , STO001_STOCK_ID STO001_STOCK_ID
    , STO001_TARGET_STOCK_ID STO001_TARGET_STOCK_ID
    , STO003_PRODUCT_LOT_ID STO003_PRODUCT_LOT_ID
    , SYS010_USER_ID SYS010_USER_ID
    , EIR001_MPI EIR001_MPI
    , ADM056_MEDICAL_ATTENTION_ID ADM056_MEDICAL_ATTENTION_ID
    , ADM094_USE_UNIT_ID ADM094_USE_UNIT_ID
    FROM
    STO020_MOVEMENT_LOG;
    Thank you in advanced!
    Edited by: lucporto on 28/08/2012 07:26

    Right. I found this way but I consider this just a quick fix, because I think there should be a better way to do this.
    create table t_clob (c_long);
    declare
    p clob;
    begin
    delete from t_clob;
    execute immediate 'insert into t_clob (select to_lob(query) from dba_mviews where owner = :1 and mview_name = :2)'
    USING 'HIS117', 'MV_STO020';
    select 'CREATE MATERIALIZED VIEW MV_STO020' || chr(10) ||
    'REFRESH ON DEMAND' || chr(10) || 'AS' || CHR(10) || mv.c_long
    into p
    from t_clob mv;
    dbms_output.put_line(p);
    end;
    Thanks all.

  • Reading package contents in SQL Plus

    Hi,
    I'd asked a similar question last week, but didn't see it responded to with a proper reply.
    Ive created a package in SQL Plus, and much like you use the DESCRIBE command to see info on tables that are created, I'd like to see the contents and script of my package to verify some contents of it.
    How can I do that? Or can I do that?
    I've read this:
    http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a77069/08_packs.htm#4376
    But it doesn't explain within how to go about doing that if indeed that is possible at all. Would anyone that knows if this can be done please reply with the way to do it?
    Thanks!

    Hi,
    You can query USER_SOURCE (or ALL_SOURCE, at your choice) to get what you need.
    Consider:
    SQL> create or replace package small is
      2    procedure Test;
      3  end;
      4  /
    Package created.
    SQL> create or replace package body small is
      2
      3  procedure Test is
      4  begin
      5    null;
      6  end;
      7
      8  end;
      9  /
    Package body created.We just created simple package, for demonstration purposes. Now, we're about to view its source:
    SQL> column text format a100
    SQL>
    SQL> select line, text
      2    from user_source
      3   where name = 'SMALL'
      4     and type = 'PACKAGE'
      5   order by line;
          LINE TEXT
             1 package small is
             2   procedure Test;
             3 end;
    SQL> select line, text
      2    from user_source
      3   where name = 'SMALL'
      4     and type = 'PACKAGE BODY'
      5   order by line;
          LINE TEXT
             1 package body small is
             2
             3 procedure Test is
             4 begin
             5   null;
             6 end;
             7
             8 end;
    8 rows selected.
    SQL>Alternatively, you can make use of DBMS_METADATA package.
    Regards.

  • DBMS_METADATA carraige returns in generated script problem

    Hi,
    does anyone know how to change the line length of the ddl generated by the DBMS_METADATA package. I'm trrying to generate ddl for a set of tables but when its generated i get the following problem
    CREATE TABLE "MYUSER"."APP_SEARCH"
    (     "USER_ID" NUMBER(5,0) NOT NULL ENABLE,
         "SEARCH_ID" NUMBER(5,0) NOT NULL ENABLE,
         "COMMENTS" VARCHAR2(100),
         "CRITERIA" LONG,
         "SEARCH_NAME" VARCHAR2(60),
         "DATE_CREATED" DATE,
         CONSTRAINT "PK_APP_SEARCH" PRIMARY KEY ("USER_ID", "SEARCH_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 TABLESPACE "TS_PK_INDEX_APPLIC
    ATION_SMALL" ENABLE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING TABLESPACE "TS_APPLIC
    ATION_SMALL"
    The problem being the TS_APPLICATION_SMALL table space name goes across 2 lines, since I am generating this into a script to be run later, the script doesn't work as it thinks the tablespace name is TS_APPLIC. I think the DBMS_METADAT package uses a fixed varchar2 width when createing the ddl inside the returned CLOB. Any ideas on how to get around this?
    Many Thanks,
    Trev.

    Joel,
    thanks for the feedback,
    I'm using the following script to generate the required create table script:
    set linesize 4000
    set heading off;
    set echo off;
    Set pages 0;
    set long 90000;
    spool createdummytable.sql
    execute DBMS_METADATA.SET_TRANSFORM_PARAM( DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
    select dbms_metadata.get_ddl('TABLE','APP_SEARCH')||';' from dual;
    execute DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');
    spool off
    set heading on
    set feedback on
    exit
    But even with the linesize set to 4000 I get the same problem. I wanted to generate the script on the client not on the server using DBMS_OUTPUT, any ideas and many thanks again,
    Trev

  • Output cut off from dbms_metadata.get_ddl

    When I execute DBMS_METADATA.GET_DDL('TABLE','table_name','schema_name'), the output for some tables is cut off. When I run it from SQL Plus or Toad, it works fine. Is there a setting that I am missing.
    Thanks

    [email protected] wrote:
    When I execute DBMS_METADATA.GET_DDL('TABLE','table_name','schema_name'), the output for some tables is cut off. When I run it from SQL Plus or Toad, it works fine. Is there a setting that I am missing.You did not tell where are you running the dbms_metadata package.
    If you can set long 10000 on the client utility try this then.
    Otherwise SQLPLUS is the best way to extract metadata and spool it to the file.
    HTH
    SS

  • About DBMS_Metadata.Get_DDL

    I am curios to know why Oracle still does not provide a function that would export the table creation script without tablespace name, PCT , double qoutes. It should give the table script, indexes and constraints scripts so that if anyone runs that script on another schema it should directly create the necessary table.

    user10566312 wrote:
    I am curios to know why Oracle still does not provide a function that would export the table creation script without tablespace name, PCT , double qoutes. It should give the table script, indexes and constraints scripts so that if anyone runs that script on another schema it should directly create the necessary table.
    They do provide such a function: GET_DDL.
    See the DBMS_METADATA package in the Packages and Types doc.
    Table 74-22 SET_TRANSFORM_PARAM: Transform Parameters for the DDL Transform
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_metada.htm#BGBJBFGE
    Works just fine for me:
    EXEC DBMS_METADATA.SET_TRANSFORM_PARAM( dbms_metadata.SESSION_TRANSFORM, 'TABLESPACE', FALSE)
    SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMP', 'SCOTT') FROM DUAL
      CREATE TABLE "SCOTT"."EMP"
       ( "EMPNO" NUMBER(4,0),
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
      CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS  ENABLE,
      CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
       REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    If you don't want those segment attributes then just disable them too
    EXEC DBMS_METADATA.SET_TRANSFORM_PARAM( dbms_metadata.SESSION_TRANSFORM, 'TABLESPACE', FALSE)
    SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMP', 'SCOTT') FROM DUAL
    EXEC DBMS_METADATA.SET_TRANSFORM_PARAM( dbms_metadata.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE)
    SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMP', 'SCOTT') FROM DUAL
      CREATE TABLE "SCOTT"."EMP"
       ( "EMPNO" NUMBER(4,0),
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
      CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") ENABLE,
      CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
       REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE

  • Programmatically modify package body source

    Hi,
    I need to write a java programm or a script that will allow me to programmatically modify the sources of all packages from several schemas.
    We need to do something similar to a search/replace in the source code of the package bodies from several schemas. Is there a way to do that ? Where should I modify the code ?
    Thank you.
    p.s. I can connect as sys.

    In PL/SQL, you can use the dbms_metadata package to get the ddl to replace the package, transform it with regexp_translate or your own procedure (substr, instr, ...), then execute.
    Regards
    Laurent

Maybe you are looking for

  • Branch Office Mail Server?

    I have Mac OS X providing mail services to about 100 users at a main office. We are opening a branch office with 20-30 users. I'm wondering if it is possible to setup another mail server for the branch office using the same domain. The users at the b

  • Universal Power Adapter

    I am traveling to India with stopover in Hong Kong and Thailand , do I need to buy any extra power adapter for my iphone , all i have is the flat pin to round pin converter ( for India ) and i saw the range on the charger says 110 to 240 and 50 to 60

  • Magic Trackpad Installation Software

    I have a new Magic Trackpad but cannot use it because there is no "Trackpad" to click on in System Preferences as per the instructions. I have the latest update to Snow Leopard installed and have no other pending software updates. I don't know what e

  • XML Purchase order - ESOA

    Hi, We are trying to configure service procurement using ESOA.Ideally once a PO is created in my ERP system a corresponding XML PO should be generated for sending it to SUS via XI. For this I have activated Business Function LOG_MM_P2P_SE_1 and workf

  • How to install transport from Note?

    Hi, a Note ask to install transport RS5K908607_part01.rar to part10.rar attached with the Note. How and where to import those files? After uncompress these files,  have RS5K908607.RS5 type. Thanks for your help Marty