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")
)
Tags: Database
Similar Questions
-
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
-
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?
TNXSee 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:
Remove the reference to SCOTT, we get another error (no surprise):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
Question: How the ADMINISTRATOR bring the DDL for a table without having to sign in as a user that owns the schema?ORA-31603: object "EMP" of type TABLE not found in schema "SYS"
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.
-
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:43Hi 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
-
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
-
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
-
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;
-
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:26The 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. -
DBMS_METADATA. GET_DDL - how it forms the exit
I call "DBMS_METADATA. GET_DDL' to get the source code for the package body, see example call below.
Can I be always sure that this will continue:
1 return the before schema name the name of the package as, for example, that: "MYSCHEMA". "" COLLECTSTATS ". Or can he return sometimes without schema/owner-name the name of the batch as a "CREATE OR REPLACE PACKAGE BODY"COLLECTSTATS"IS".
2 he will always be in uppercase letters the part "owner.packagename"?
3 wil lthere always be quotation marks surrounding the package name and the name of the owner as "MONSCHEMA". "' COLLECTSTATS '?
select DBMS_METADATA.GET_DDL('PACKAGE_BODY','COLLECTSTATS','MYSCHEMA') from DUAL; Result: CREATE OR REPLACE PACKAGE BODY "MYSCHEMA"."COLLECTSTATS" IS PROCEDURE save_log(p_logrec IN LiveStatsLog%ROWTYPE) IS
There are a number of things that you can control the output of dbms_metadata using the procedures of set_transform_param. Apparently, at least in 10G, is not one of them, even if I thought it was.
Consult the manual of the PL/SQL Packages and Types reference for your version of Oracle to see what is available.
John
-
Question about SELECT DBMS_METADATA. GET_DDL
Hello
In reading the other posts, I found this interesting statement:
I thought it would be useful. When I tried as user SCOTT, the result I got is 'incomplete', as shown below:SELECT DBMS_METADATA.GET_DDL('TABLE','TABLE_NAME') FROM DUAL;
looks like the function smothered in half way through.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>
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_dll on db link
Oracle 11.2.0.3 on Oracle Linux 5 64-bit
I probably just need a second set of eyes...
SQL > show user
The USER is "ESTEVENS".
SQL > select master, dba_db_links db_link
2;
AAA PUBLIC
BBB PUBLIC. WORLD
CCC AUDIENCE. WORLD
CCC PUBLIC
DDD PUBLIC. WORLD
PUBLIC EEE
FFF PUBLIC
GGG PUBLIC
HHH PUBLIC
JJJ PUBLIC
KKK_UPDATE PUBLIC. WORLD
KKK PUBLIC. WORLD
PUBLIC LLL. WORLD
MMM_UPDATE PUBLIC. WORLD
PUBLIC MMM. WORLD
15 selected lines.
SQL >--
SQL > declare clob c;
2 start
3 for t in (select db_link
dba_db_links 4
5 )
6 loop
7. Select dbms_metadata.get_ddl ('DB_LINK', t.db_link) in the double c;
8 dbms_output.put_line (c);
9 dbms_output.put(';');
10 end of loop;
11 end;
12.
declare the clob c;
*
ERROR on line 1:
ORA-31603: object type as Db_link ' AAA' was not found in the schema
"ESTEVENS".
ORA-06512: at "SYS." Dbms_metadata", line 5088
ORA-06512: at "SYS." Dbms_metadata", line 7589
ORA-06512: at line 1
ORA-06512: at line 7
Yes, the "ESTEVENS" user has dba role.
Pl/sql block works as expected when the selection of dba_tablespaces and dba_directories.
Google the error message and the most promising link was ORA-31603 on dbms_metadata.get_dll for only dblinks , but it was abandoned without a final resolution. Here, the OP seemed to have the same problem - works for "everything" except dba_db_links.
AAA is not owned by ESTEVENS, but by the PUBLIC
Include the appropriate schema name 3rd argument in the call GET_DDL
Maybe you are looking for
-
I have Window XP. I have the .NET Framework 3.5 and 4.0. Among the programs I need net framework v 1.1. What can I safely intall net framework v 1.1 rund some of my programs without affecting my computer and because of problems with Net Framework
-
UFT install error file not found
When you install MISS, I get this error message. I am able to locate the file, but I don't know if the record is correct. What should do?
-
Startup Repair still running after 2 hours 20 minutes.
HP Pavilion dv6t-6100 Windows 7 Home Premium 64-bit Removal of battery - based power alternative When I tried to boot my laptop this morning, he got on the screen Windows logo, sitting there for about 15 seconds (more than normal) and then a blue scr
-
Can't push to the physical device but can push to the Simulator
Anyone know why I can't push my real BlackBerry but I can push to the Simulator? I'm just accessing this site on my test pc and pointing to our production server BES. http://BES_Server:17080 / push? DESTINATION = MyPin & PORT = 7874 & REQUESTURI = l
-
"Adobe Photoshop has stopped working".
Problem #1: Yesterday, out of the blue, when I tried to open Photoshop CS5.1, I got a pop up insisting I install Photoshop Extended. I have never possessed enlarged so the pop up makes no sense. I could leave the installation license agreement / expa