strange dbms_metadata.get_ddl TS DDL

11.2.0.2 Oracle 64-bit

Oracle Linux 5

In another issue (isn't that where we find always the uh, interesting things?)  I came across something odd about a definition of TS returned by dbms_metadata.  Launched a couple of other requests for related information together.  Note that the supposed definition of the ts includes an alteration of a redo log file.

Sign me - stumped.

SQL > SELECT DBMS_METADATA. GET_DDL ('TABLESPACE', 'PSUNDOTS') of double;

DBMS_METADATA. GET_DDL ('TABLESPACE', 'PSUNDOTS')

--------------------------------------------------------------------------------

CREATE UNDO TABLESPACE "PSUNDOTS" DATA FILE

' / u01/oradata/fs91dmo/psundots01.dbf' 314572800 SIZE

AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M.,

' / u01/oradata/fs91dmo/redo03.log' 314572800 SIZE

AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M

BLOCKSIZE 8192

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

ALTER DATABASE DATAFILE

' / u01/oradata/fs91dmo/psundots01.dbf' 3145728000 RESIZE

ALTER DATABASE DATAFILE

' / u01/oradata/fs91dmo/redo03.log' 3145728000 RESIZE

1 selected line.

SQL > select file_name

2 of dba_data_files

3 where nom_tablespace = 'PSUNDOTS ';

FILE_NAME

---------------------------------------------

/U01/oradata/fs91dmo/psundots01.dbf

1 selected line.

SQL > select group #,.

2 Member

3 v $ logfile

4 order of 1,2;

GROUP # MEMBERS

---------- ---------------------------------------------

1 /u01/oradata/fs91dmo/redo01.log

2 /u01/oradata/fs91dmo/redo02.log

3 /u01/oradata/fs91dmo/redo03.log

3 selected lines.

SQL >--

SQL > spo off

Hello

It is clearly a bug:

Bug 10177856 - DBMS_METADATA.get_ddl ('tablespace',...) includes wrongly tempfiles and redo-log online (Doc ID 10177856.8)

Kind regards

Bashar

Tags: Database

Similar Questions

  • grant for dbms_metadata.get_ddl on objects in another schema

    In Oracle 11 g R2, I use dbms_metadata.get_ddl to get the DDL to another schema, but I got an error:

    ORA-31603: object not found 'IS_SNMP_DATA' of type TABLE in the schema "TXV.

    that grant is necessary for this package to get from another schema ddl?
    I tried with authid current_user (that I found on google), but no result...

    See the following example:

    SQL> create user us_one identified by us1;
    User created.
    
    SQL> grant connect, resource to us_one;
    Grant succeeded.
    
    SQL> create user us_two identified by us2;
    User created.
    
    SQL> grant connect, resource to us_two;
    Grant succeeded.
    
    SQL> conn us_one/us1
    Connected.
    SQL> create table t (id number);
    
    Table created.
    
    SQL> grant select on t to us_two;
    Grant succeeded.
    
    SQL> conn / as sysdba
    Connected.
    
    SQL> grant execute on dbms_metadata to us_two;
    
    Grant succeeded.
    
    SQL> conn us_two/us2
    Connected.
    
    SQL> select dbms_metadata.get_ddl('TABLE','T','US_ONE') from dual;
    ERROR:
    ORA-31603: object "T" of type TABLE not found in schema "US_ONE"
    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
    
    no rows selected
    
    SQL> conn / as sysdba
    Connected.
    SQL> grant select_catalog_role to us_two;
    
    Grant succeeded.
    
    SQL> conn us_two/us2
    Connected.
    SQL> select dbms_metadata.get_ddl('TABLE','T','US_ONE') from dual;
    
    DBMS_METADATA.GET_DDL('TABLE','T','US_ONE')
    --------------------------------------------------------------------------------
    
      CREATE TABLE "US_ONE"."T"
       (    "ID" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRA
    
    SQL> 
    
  • get the table script using dbms_metadata.get_ddl but with clob field

    Thus, Oracle 11g R2...
    I use dbms_metadata.get_ddl for table scripts and it works fine...

    now, I have a table with clob field, and it does not work... I got an error "missing a closing parenthesis (ora-0907) '...
    I could paste a script I had, but I don't think that it makes no sense...

    does anyone have an experience on the use of this package on clob tables?


    TNX

    See this code.

    DECLARE
      myddl clob;
      PROCEDURE print_clob(p_clob in clob) as
        l_offset number default 1;
      BEGIN
        loop
          exit when l_offset > dbms_lob.getlength(p_clob);
          dbms_output.put_line(dbms_lob.substr(p_clob, 255, l_offset));
          l_offset := l_offset + 255;
        end loop;
      END print_clob;
      FUNCTION get_metadata return clob is
        h   number;
        th  number;
        doc clob;
      BEGIN
        h := dbms_metadata.open('TABLE');
        dbms_metadata.set_filter(h, 'SCHEMA', 'HR');
        dbms_metadata.set_filter(h, 'NAME', 'EMPLOYEES');
        th := dbms_metadata.add_transform(h, 'MODIFY');
        th := dbms_metadata.add_transform(h, 'DDL');
        --dbms_metadata.set_transform_param(th,'SEGMENT_ATTRIBUTES',false);
        doc := dbms_metadata.fetch_clob(h);
        dbms_metadata.CLOSE(h);
        return doc;
      END get_metadata;
    BEGIN
      myddl := get_metadata;
      print_clob(myddl);
    END;
    

    This procedure of print_ddl I took of the documentation.
    Use of the long VALUE. See, in the first example out put is truncated.

    SQL> SELECT dbms_metadata.get_ddl('TABLE','EMP','SCOTT') FROM dual;
    
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
    --------------------------------------------------------------------------------
    
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
    
    SQL> set long 10000
    SQL> /
    
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
    --------------------------------------------------------------------------------
    
      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")
    
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
    --------------------------------------------------------------------------------
      USING INDEX 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 "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) 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 "USERS"
    
    SQL> SET LINESIZE 132
    SQL> SET pagesize 0
    SQL> SET LONG 1000000
    SQL> /
    
      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
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) 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 "USERS"
    
    SQL>
    
  • Another question about dbms_metadata.get_ddl

    Hello

    Recorded in as 'sys as sysdba' I tried to get the DDL for the EMP table in the SCOTT schema. Here is the output I got:
      1* select scott.dbms_metadata.get_ddl('TABLE', 'EMP') from dual
    SQL> /
    select scott.dbms_metadata.get_ddl('TABLE', 'EMP') from dual
           *
    ERROR at line 1:
    ORA-00904: "SCOTT"."DBMS_METADATA"."GET_DDL": invalid identifier
    Remove the reference to SCOTT, we get another error (no surprise):
    ORA-31603: object "EMP" of type TABLE not found in schema "SYS"
    Question: How the ADMINISTRATOR bring the DDL for a table without having to sign in as a user that owns the schema?

    Thank you

    John.

    He must inform the owner of this object when running DBMS_METADATA of SYS.

    If we describe DBMS_METADATA

    FUNCTION GET_DDL RETURNS CLOB
     Argument Name                  Type                    In/Out Default?
     ------------------------------ ----------------------- ------ --------
     OBJECT_TYPE                    VARCHAR2                IN
     NAME                           VARCHAR2                IN
     SCHEMA                         VARCHAR2                IN     DEFAULT
     VERSION                        VARCHAR2                IN     DEFAULT
     MODEL                          VARCHAR2                IN     DEFAULT
     TRANSFORM                      VARCHAR2                IN     DEFAULT
    

    So there must be another SCHEMA parameter when running DBMS_METADATA of SYS.

  • grant dbms_metadata.get_ddl wanted

    Hi all! I need help. I want to get in clob a ddl of an object. What I am doing wrong?

    Select the owner, constraint_name from dba_constraints where constraint_name = "TOME_KYTE_IS_UNIQUE";


    OWNER CONSTRAINT_NAME
    TOMKYTE TOME_KYTE_IS_UNIQUE




    Create procedure tomkyte.testprint as

    CLOB text;

    Start
    Select DBMS_METADATA. GET_DDL ('CONSTRAINT', 'TOME_KYTE_IS_UNIQUE', 'TOMKYTE')
    in the text of the double;

    dbms_output.put_line('1');

    end;

    -----
    procedure created

    -----
    Start
    tomkyte.testprint; -I plugged as tomkyte
    end;



    ORA-31603: object "TOME_KYTE_IS_UNIQUE" of type CONSTRAINT was not found in the schema TOMKYTE

    This who should I agree with tom that he can get atleast its own objects ddl?

    Thanks in advance.

    Instead of DBA_constraints you can use USER_CONSTRAINTS and see how it works

    create or replace procedure tomkyte.buildConstraint(
    cons_name varchar2,
    cons_owner varchar2,
    cons_new_owner varchar2) AS
    
    stat clob;
    e varchar2(4000);
    var varchar2(300);
    begin
    select DBMS_METADATA.GET_DDL('*CONSTRAINT*',cons_name,cons_owner) into stat from dual;
    dbms_output.put_line(stat);
    end;
    

    Try to replace the CONSTRAINT by REF_CONSTRAINT

    Thnks to metalink

    Published by: Maran Viswarayar Sep 12, 2008 17:26

  • using dbms_metadata for the ddl to create directories

    Hello
    I'm working on creating a test database, which is a copy of production for 11g upgrade test. I want to get all my production database DDL to create all the directories in the new test database. I tried using dbms_metadata for it-
    Here is the code I tried to use. However, when I query the my_metadata table, nothing in there. Can someone help me with this please?

    DROP TABLE my_metadata;
    CREATE TABLE my_metadata (md CLOB);

    CREATE OR REPLACE PROCEDURE progp1_directories_extract
    AS
    hndl NUMBER; -dbms_metadata handle
    e NUMBER; -transform handle
    CLOB DDL; -Individual CLOB from the database
    BEGIN
    hndl: = DBMS_METADATA. OPEN ("DATABASE_EXPORT"); -Open the metadata
    DBMS_METADATA.set_Filter (hndl, 'INCLUDE_PATH_EXPR', ' = "DIRECTORY" "); -Filter the data according to the case
    th: = DBMS_METADATA.add_transform (hndl, 'DDL'); -Get the Handle of the transformation
    DBMS_METADATA.SET_TRANSFORM_PARAM (th, 'SQLTERMINATOR', TRUE); -Include the semicolon

    LOOP
    DDL: = DBMS_METADATA.fetch_clob (hndl); -Loop through the result set, inserting in our temporary table
    DDL OUTPUT IS NULL;

    INSERT INTO my_metadata
    (md)
    VALUES (DDL);
    COMMIT;
    END LOOP;
    DBMS_METADATA. CLOSE (hndl);
    EXCEPTION
    WHILE OTHERS
    THEN
    NULL;
    END;
    /
    display errors

    Hello

    You can get the DDL for the directory running sql in the source database.

    Select 'create directory' | OWNER: '. ' || DIRECTORY_NAME |' like ' | " ' || DIRECTORY_PATH | " ' || ';' in dba_directories;

    Concerning

  • How to call dbms_metadata.get_ddl of ODP?

    This package function returns a CLOB.

    Whenever I call it, I get the error ORA-22275.

    I looked at the examples and I can't figure out what I need to do. From what I can find by looking at examples of Microsoft, I need create sort of a temporary CLOB in the database, and then somehow a back reference in my call to the package.

    Does anyone have an example on how to do this?

    Here is the code I have, but it keeps returning ORA-22275

    using (OracleConnection oraConn = OracleConnection (targetConnString)) new
    {
    OracleParameter parmObjectType = new OracleParameter();
    parmObjectType.OracleDbType = OracleDbType.Varchar2;
    parmObjectType.ParameterName = 'OBJECT_TYPE ';
    parmObjectType.Value = objectType;

    OracleParameter parmObjectName = new OracleParameter();
    parmObjectName.OracleDbType = OracleDbType.Varchar2;
    parmObjectName.ParameterName = "NAME";
    parmObjectName.Value = objectName;

    OracleParameter parmObjectOwner = new OracleParameter();
    parmObjectOwner.OracleDbType = OracleDbType.Varchar2;
    parmObjectOwner.ParameterName = 'SCHEMA ';
    parmObjectOwner.Value = objectOwner;

    oraConn.Open ();

    OracleCommand cmd = new OracleCommand();
    cmd connection group oraConn;.

    cmd.CommandText = "declare clob xx; begin dbms_lob.createtemporary (xx, false, 0); : tempclob: = xx; end; « ;
    cmd. Parameters.Add (new OracleParameter ("tempclob", OracleDbType.Clob)). Direction = ParameterDirection.Output;

    cmd ExecuteNonQuery());

    OracleClob tempclob is cmd (OracleClob). Parameters [0]. Value;
    cmd Parameters.Clear ();

    OracleParameter parmScript = new OracleParameter();
    parmScript.OracleDbType = OracleDbType.Clob;
    parmScript.Direction = ParameterDirection.ReturnValue;
    parmScript.Value = tempclob;


    cmd.CommandText = "dbms_metadata.get_ddl";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd. Parameters.Add (parmObjectType);
    cmd. Parameters.Add (parmObjectName);
    cmd. Parameters.Add (parmObjectOwner);
    cmd. Parameters.Add (parmScript);

    cmd ExecuteNonQuery()); <-this is where the code does not work!


    oraConn.Close ();

    }

    Published by: [email protected] on March 23, 2009 14:43

    Hi Enzo,

    Have you run my code CORRECT, exactly as planned?

    It's just that I look back on your original post that looks like you can add parameters in the right order. ODP is BindByPosition, so you must ensure that the Clob gets first instruction executed ultimately added to the collection will be something like start: 1: = dbms_metadata.get_ddl (: 2:3.. etc).

    If I intentionally add parameters to the collection in the wrong order, 22275 results. If happens?

    Greg

  • On DBMS_Metadata.Get_DDL

    I'm curios to know why Oracle does not always provide a feature which would export the script to create table without name of the tablespace, PCT, double qoutes. It should give the script table, indexes and constraints of the scripts so that if someone is running this script on another schema it should create the necessary table directly.

    user10566312 wrote:

    I'm curios to know why Oracle does not always provide a feature which would export the script to create table without name of the tablespace, PCT, double qoutes. It should give the script table, indexes and constraints of the scripts so that if someone is running this script on another schema it should create the necessary table directly.

    They offer such a function: GET_DDL.

    See the DBMS_METADATA package in the packages doc and Types.

    Table 74-22 SET_TRANSFORM_PARAM: transform parameters for the transformation of the DDL

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28419/d_metada.htm#BGBJBFGE

    Works 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),
    VARCHAR2 (9) "JOB."
    "MGR" NUMBER (4,0).
    "HIREDATE" DATE,
    "SAL" NUMBER (7.2).
    NUMBER (7.2) "COMM"
    "DEPTNO" NUMBER (2.0).
    'PK_EMP' CONSTRAINT PRIMARY KEY ('EMPNO')
    BY USING THE PCTFREE 10 INITRANS INDEX 2 MAXTRANS 255 CALCULATE STATISTICS ENABLE,
    "FK_DEPTNO' FOREIGN KEY ('DEPTNO') CONSTRAINT
    REFERENCES 'SCOTT '. "" ENABLE DEPT "("DEPTNO")
    ) CREATION OF IMMEDIATE SEGMENT
    PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255 NOCOMPRESS SLAUGHTER

    If you do not 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),
    VARCHAR2 (9) "JOB."
    "MGR" NUMBER (4,0).
    "HIREDATE" DATE,
    "SAL" NUMBER (7.2).
    NUMBER (7.2) "COMM"
    "DEPTNO" NUMBER (2.0).
    ACTIVATE THE KEY PRIMARY CONSTRAINT 'PK_EMP' ('EMPNO'),
    "FK_DEPTNO' FOREIGN KEY ('DEPTNO') CONSTRAINT
    REFERENCES 'SCOTT '. "" ENABLE DEPT "("DEPTNO")
    )

  • DBMS_METADATA. GET_DDL does not return the entire procedure. His truncated

    SET echo off; set pagesize 0; SET long 500000; spool GenerateProcedure_Creation.sql begin dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true); dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', false); end; SELECT DBMS_METADATA.GET_DDL(u.object_type,u.object_name,u.owner) DDL from dba_objects u where u.OBJECT_TYPE = 'PROCEDURE' and owner in ('ADMIN'); spool off; 

    This returns some of the procedures as truncated.

    RUN THE FOLLOWING before RUNNING YOUR STATEMENT in sqlplus:

    long value 1000000

    then try

  • DBMS_METADATA. GET_DDL in a function

    Is it possible to call dbms_metadata.get_ddl of inside of a function?

    I am creating a process to copy the DDL to a different schema. Running the command sql itself works well:

    Select dbms_metadata.get_ddl)

    "TABLE."

    object_name,

    OWNER

    )

    from dba_objects

    where object_name = 'INPUT_TABLE. "

    But by adding the exact same command in a function returns an error:

    ORA-31603: object "INPUT_TABLE" of type TABLE not found in the schema "STAGE".

    I assume that the user has all the correct privileges or that the first step would not work.  Is there a way to get around this?

    Thank you very much.

    No doubt that The Oracle (tm) co-operative FAQ - privileges in PL/SQL users

  • Parameter DBMS_METADATA. GET_DDL out of materialized views

    Hi all.
    My version of Oracle's 10g.

    I am extracting DDL for all database objects using the DBMS_METADATA package. I use SET_TRANSFORM_PARAM to configure the output because I need a sql code simple, without information about the attributes of storage spaces, storage and segment. Everything works well except when I work with mviews object types. I can't remove the information about the attributes of the tablespace, storage or segment for materialized views.

    I would like to know if there is a problem related to this topic. Or there is something missing in my code?

    I tried to specify the type of object such as another parameter on DBMS_METADATA. SET_TRANSFORM_PARAM but not work too.
    The only parameter transform that works very well with materialized views is the SQLTERMINATOR.

    ------
    See how I did:

    declare
    CLOB vDDL;
    Start
    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') in vDDL FROM DUAL;
    dbms_output.put_line (vDDL);
    end;
    -------
    and how the output is:

    CREATE A MATERIALIZED VIEW 'HIS117_CHECK '. "" MV_STO020 ".
    PCTFREE 10 BUNCH OF ORGANIZATION PCTUSED 40 INITRANS MAXTRANS 255 NOCOMPRESS LOGGING 1
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "TS_HIS117".
    IMMEDIATE CONSTRUCTION
    USING INDEX
    REFRESH THE STRENGTH TO DEMAND
    WITH A KEY PRIMARY WITH THE HELP OF DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE THE QUERY REWRITING
    IN 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
    Of
    STO020_MOVEMENT_LOG;

    Thank you in advance!

    Published by: lucporto on 08/28/2012 07:26

    The LONG data type conversion is explained on http://asktom.oracle.com if you use the search feature.
    I could not find real pointers to your original question it.

  • DDL database off dbms_metadata table

    Hi all
    I use under query to get the DDL for all database objects in my current schema.

    SELECT dbms_metadata.get_ddl (replace (OBJECT_TYPE, ' ', '_'), OBJECT_NAME, OWNER)
    FROM DBA_OBJECTS
    WHERE OBJECT_TYPE in ('SEQUENCE',
    'PROCEDURE ',.
    "DATABASE LINK",
    'PACKAGE ',.
    'PACKAGE BODY ',.
    "MATERIALIZED VIEW.
    "TABLE."
    "INDEX."
    "DISPLAY."
    'FUNCTION')
    AND
    OWNER = "SCHEMA1";

    I get the DDL for tables, but I don't get the part comment (for example, the description of the column).
    Does anyone know how to get the column via dbms_metadata package-level description...?
    Please help,
    Thanks in advance
    J

    J1604 wrote:
    Anyway we can answer my query. ?

    SELECT  dbms_metadata.get_ddl(replace(OBJECT_TYPE, ' ', '_'), OBJECT_NAME,OWNER),
            CASE
              WHEN OBJECT_TYPE = 'TABLE' AND 1 = (SELECT 1 FROM DBA_TAB_COMMENTS c WHERE c.OWNER = o.OWNER AND c.TABLE_NAME = o.TABLE_NAME)
                THEN DBMS_METADATA.get_dependent_ddl('COMMENT',OBJECT_NAME,OWNER)
            END
      FROM  DBA_OBJECTS o
      WHERE OBJECT_TYPE in (
                            'SEQUENCE',
                            'PROCEDURE',
                            'DATABASE LINK',
                            'PACKAGE',
                            'PACKAGE BODY',
                            'MATERIALIZED VIEW',
                            'TABLE',
                            'INDEX',
                            'VIEW',
                            'FUNCTION'
                           )
      AND SUBOBJECT_NAME IS NULL
      AND OWNER = 'SCHEMA1'
    /
    

    I added AND SUBOBJECT_NAME IS NULL since, for example, partitioned tables/index/lob will have several lines in DBA_OBJECTS - one line per object itself with the name of subobject null + a real line by partition with name of subobject.

    SY.

  • Question about SELECT DBMS_METADATA. GET_DDL

    Hello

    In reading the other posts, I found this interesting statement:
    SELECT DBMS_METADATA.GET_DDL('TABLE','TABLE_NAME') FROM DUAL;
    I thought it would be useful. When I tried as user SCOTT, the result I got is 'incomplete', as shown below:
    SQL> select dbms_metadata.get_ddl('TABLE', 'EMP') from dual;
    
    DBMS_METADATA.GET_DDL('TABLE','EMP')
    --------------------------------------------------------------------------------
    
    
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
    
    
    SQL> describe emp;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
    
     EMPNO                                     NOT NULL NUMBER(4)
     ENAME                                              VARCHAR2(10)
     JOB                                                VARCHAR2(9)
     MGR                                                NUMBER(4)
     HIREDATE                                           DATE
     SAL                                                NUMBER(7,2)
     COMM                                               NUMBER(7,2)
     DEPTNO                                             NUMBER(2)
    
    SQL> select dbms_metadata.get_ddl('TABLE', 'DEPT') from dual;
    
    DBMS_METADATA.GET_DDL('TABLE','DEPT')
    --------------------------------------------------------------------------------
    
    
      CREATE TABLE "SCOTT"."DEPT"
       (    "DEPTNO" NUMBER(2,0),
            "DNAME" VARCHAR2(14
    
    
    SQL>
    looks like the function smothered in half way through.

    Question: No idea why GET_DDL did not return all DDL for tables above?

    I thought that maybe it was a question of the privileges of the user, so I tried to sys as sysdba, then he tried to find EMP in SYS (which is obviously not there). How the ADMINISTRATOR bring the DDL for a table without having to sign in as a user that owns the schema?

    Thank you for your help,

    John.

    You need to set the LONG and LONGCHUNKSIZE parameters to sql * higher level for a complete result.

  • DBMS_METADATA. GET_DDL / materialized view

    I can use something like "select dbms_metadata.get_ddl (< object_Type >, < object_Name >) of double" to get the ddl for tables, views, etc. ; However, this doesn't seem to work for me now for the 11.1.0.7.0 version. What should I do to recover the ddl of a materialized view?

    Œuvres:

    SELECT dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'V_CUSTOMER')
    FROM dual;
    

    Does not work:

    SELECT dbms_metadata.get_ddl('MATERIALIZED VIEW', 'V_CUSTOMER')
    FROM dual;
    

    Even for the other types-word-2: "PACKAGE_BODY" is correct, and "BODY of PACKAGE" is not correct.

    Edited by: CharlesRoos May 21, 2010 05:16

  • DBMS_METADATA. GET_DDL is back NOCOMPRESS, NOLOGGING etc.

    How can the NOCOMPRESS and ' NLS_CALENDAR = GREGORIAN "(et parfois NOLOGGING) clause can be avoided in the exit plese?"


    We are on 10.2.0.5

    SQL > set linesize 10000

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

    SQL > exec DBMS_METADATA. SET_TRANSFORM_PARAM (DBMS_METADATA. False SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES',);

    SQL > SELECT DBMS_METADATA. GET_DDL ('TABLE', 'RANGE_SALES', 'CHAKRAA4') of double;

    DBMS_METADATA. GET_DDL ('TABLE', 'RANGE_SALES', 'CHAKRAA4')

    -------------------------------------------------
    CREATE TABLE 'CHAKRAA4 '. "" RANGE_SALES ".
    ('PROD_ID' NUMBER (6,0),)
    NUMBER OF "CUST_ID",.
    DATE OF THE "TIME_ID"
    "CHANNEL_ID' CHAR (1).
    NUMBER (6.0) "PROMO_ID."
    NUMBER (3.0) "QUANTITY_SOLD."
    NUMBER (10.2) "AMOUNT_SOLD".
    )
    PARTITION BY RANGE ("TIME_ID")
    (PARTITION 'SALES_Q1_2011' VALUES LESS THAN (TO_DATE (' 2011-04-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN ')) NOCOMPRESS,)
    PARTITION "SALES_Q2_2011" VALUES LOWER THAN (TO_DATE (' 2011-07-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN ')) NOCOMPRESS,.
    PARTITION "SALES_Q3_2011" VALUES LOWER THAN (TO_DATE (' 2011-10-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN ')) NOCOMPRESS,.
    "SALES_Q4_2011" VALUES LESS THAN (MAXVALUE) NOCOMPRESS PARTITION)

    Try to use the function REPLACE

    SELECT REPLACE(REPLACE(DBMS_METADATA.GET_DDL('TABLE', 'MY_TEST', 'SCOTT'),
                           'NOCOMPRESS',
                           NULL),
                   'NOLOGGING',
                   NULL)
      from dual;
    

Maybe you are looking for