DBMS_METADATA.GET_DDL Not working
Hi All,
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
I am creating table as:
create table XX as select * from fnd;
select DBMS_METADATA.GET_DDL('TABLE','xx') from dualI get the below given error:
Error starting at line 1 in command:
select DBMS_METADATA.GET_DDL('TABLE','xx') from dual
Error report:
SQL Error: ORA-31603: object "xx" of type TABLE not found in schema "A395513"
ORA-06512: at "SYS.DBMS_METADATA", line 1548
ORA-06512: at "SYS.DBMS_METADATA", line 1585
ORA-06512: at "SYS.DBMS_METADATA", line 1902
ORA-06512: at "SYS.DBMS_METADATA", line 2793
ORA-06512: at "SYS.DBMS_METADATA", line 4333
ORA-06512: at line 1
31603. 00000 - "object \"%s\" of type %s not found in schema \"%s\""
*Cause: The specified object was not found in the database.
*Action: Correct the object specification and try the call again.
Oracle names are stored in dictionary in upper case (unless quoted name is used at create time). Use XX as table name:
SQL> create table XX as select * from emp;
Table created.
SQL> set long 1000
SQL> select DBMS_METADATA.GET_DDL('TABLE','xx') from dual;
ERROR:
ORA-31603: object "xx" of type TABLE not found in schema "SCOTT"
ORA-06512: at "SYS.DBMS_METADATA", line 1548
ORA-06512: at "SYS.DBMS_METADATA", line 1585
ORA-06512: at "SYS.DBMS_METADATA", line 1902
ORA-06512: at "SYS.DBMS_METADATA", line 2793
ORA-06512: at "SYS.DBMS_METADATA", line 4333
ORA-06512: at line 1
no rows selected
SQL> select DBMS_METADATA.GET_DDL('TABLE','XX') from dual;
DBMS_METADATA.GET_DDL('TABLE','XX')
CREATE TABLE "SCOTT"."XX"
( "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)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
DBMS_METADATA.GET_DDL('TABLE','XX')
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
SQL> SY.
Similar Messages
-
Dbms_metadata.get_ddl not working in 11g
Hi All,
I need a quick help from you. Following is not working in 11g.
dbms_metadata.get_ddl( 'MATERIALIZED_VIEW', Mview_name, owner )
It is throwing me an error saying the Materialized view does not exist, though its exist.
Please let me know, what is wrong here with 11g.Please let me know, what is wrong here with 11g.No problem here: Can you reproduce these steps:
SQL> select * from v$version where rownum = 1
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
1 row selected.
SQL> create materialized view mv_dummy as select * from dual
Materialized View created.
SQL> select dbms_metadata.get_ddl ('MATERIALIZED_VIEW', 'MV_DUMMY', user) ddl from dual
DDL
CREATE MATERIALIZED VIEW "MICHAEL"."MV_DUMMY" ("DUMMY")
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOG
GING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX
REFRESH FORCE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE
AS select * from dual
1 row selected.? -
Why dbms_metadata.get_ddl can not work for db link?
db: 10.2.4
os: RH linux 5
our problem is that we can not get ddl from dbms_metadata.get_ddl for database link, however the db link does exist here as below.
SQL> select * from dba_db_links where owner='XXRPTH';
OWNER DB_LINK USERNAME HOST CREATED
XXR TO_DOPDB.XXR.COM TEST db_opdb 18-FEB-08
XXR XXRPTH_OPDBC.XXR.COM TEST db_opdb 15-JUL-08
XXR XXRPTH_BLIS.XXR.COM BLIS dbls 02-JUN-08
SQL> select dbms_metadata.get_ddl('DB_LINK','XXRPTH_OPDBC.XXR.COM','XXR') from dual;
ERROR:
ORA-31603: object "XXRPTH_OPDBC.XXR.COM" of type DB_LINK not found in schema "XXR"
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
appreciate for any guides
thanksI ran into this in a slightly different form, I can't remember all the rules and details, but to work around it I had to specify a fake name appendage in the db link creation in order to keep it from automatically appending the global domain.
Something like
create database link abcdef.remotealias connect to ... using 'remotealias'
rather than
create database link abcdef connect to... using 'remotealias'
At least I think it was fake, I was flopping around trying things until I got it to work, and I wound up making it the same as the tnsnames alias. I think I decided I didn't have to, but left it as the lesser of two confusions, and was miffed that the creation scripts I had been using for years suddenly had to be fixed. Yeah, it was my own damned fault, but I still think the way this works is crazy. Now hopefully someone will explain this simply so I look foolish. -
Dbms_metadata.get_ddl returns text of table script but not the view
Hi all
I am using a DDL trigger like
CREATE OR REPLACE TRIGGER SYS.log_ddl AFTER DDL
ON DATABASE
declare
n_text varchar2(2000);
begin
if ora_sysevent='CREATE' and ora_dict_obj_type='VIEW' then
select dbms_metadata.get_ddl
(ora_dict_obj_type ,ora_dict_obj_name,ora_dict_obj_owner)
into n_text from dual;
elsif ora_sysevent='CREATE' and ora_dict_obj_type='TABLE' then
select dbms_metadata.get_ddl
(ora_dict_obj_type ,ora_dict_obj_name,ora_dict_obj_owner) into n_text from dual
end if;
end;
on execution
the first condition produces an error if the view does not already exists
ORA-31603: object "TEST" of type VIEW not found in schema "SHAI"
but the second condition of table creation executs successfuly and return the script of the table
what can be the main theory behind this.I think some of the bug fixes were targeted for 9.2.0.5, but I can't tell you for certain.
One of the things I really don't like about DBMS_METADATA is that it returns an error if a specified object does not exist. For example, I created a sql script that would accept a schema name as the input parameter and would generate all the ddl for the schema. If the schema did not have a particular object, for example a sequence, the call to DBMS_METADATA to generate the sequence ddl would return an error instead of returning nothing. I had error checking in the script, so this caused problems. (Oracle's response is that this is expected behaviour).
This might be what is happening with your call.
Dan -
Dbms_metadata.get_ddl output format is not runable.
Hi,
I am using dbms_metadata.get_ddl to extract the objects. But the output returned is not runable.
In output lines are broken so it makes unable to run that code.
Ex. If I run this for all the synonyms like this.
set pagesize 0
set long 90000
set feedback off
set echo off
spool /tmp/FixSyn.out
select
DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1')
from
dba_objects u
where
object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
spool off;
Output from this is coming like this.
CREATE OR REPLACE SYNONYM "ADMINSRV_D1"."ASSTATEAPPORVALTYPE222" FOR "ADMINSRV
_D1"."ASSTATEAPPORVALTYPE";
CREATE OR REPLACE SYNONYM "ABC"."ASSTATEAPPORVALTYPE3" FOR "ADMINSRV_D
1"."ASSTATEAPPORVALTYPE";
This is broken in multiple lines so not possible to run this.
Please provide any solution to fix this output.
Thanks a lot,
Amit.How about using word_wrapped
set pagesize 0
set long 90000
set lines 131
column txt format a121 word_wrapped
set feedback off
set echo off
spool /tmp/FixSyn.out
select
DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1') txt
from
dba_objects u
where
object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
spool off;
For help on Column and default attributes.
SQL> help column
You can also check asktom replies.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:30802454515375
Regards,
Sabdar Syed. -
hi all,
i can not generate the DDL of java class in 10g r2 as below.
sys@RPTDB > select dbms_metadata.get_ddl('JAVA_SOURCE','BRStatus','HDADMIN') from dual;
ERROR:
ORA-31603: object "BRStatus" of type JAVA_SOURCE not found in schema "HDADMIN"
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
actually, the object exists.
sys@RPTDB > select object_name,object_type,owner from dba_objects where object_name='BRStatus';
OBJECT_NAME OBJECT_TYPE OWNER
BRStatus JAVA CLASS HDADMIN
thanks for any inputs.sys@RPTDB > select dbms_metadata.get_ddl('JAVA SOURCE','BRStatus','HDADMIN') from dual;
ERROR:
ORA-31600: invalid input value JAVA SOURCE for parameter OBJECT_TYPE in
function GET_DDL
ORA-06512: at "SYS.DBMS_METADATA", line 2682
ORA-06512: at "SYS.DBMS_METADATA", line 2733
ORA-06512: at "SYS.DBMS_METADATA", line 4333
ORA-06512: at line 1
no rows selected
did you really get right results with JAVA SOURCE? my version is 10g r2 -
Stange error when using dbms_metadata.get_ddl in PL/SQL procedure
Basic info:
Oracle 10.2.0.4.0 on linux.
I'm trying to extract ddl of indexes that I drop and recreate frequently during monthly loads and store it in a table.
This statement works on the command line:
insert into saved_indexes
select index_name,dbms_metadata.get_ddl('INDEX',index_name,owner_name)
from sys.all_indexes
where owner = owner_name
and table_name = table_name;
commit;
The table 'saved_indexes' is a two column table with a varchar2(40) and a CLOB.
When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.
PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2) IS
v_errorcode number(8);
v_errortext varchar2(1000);
v_start_time date;
BEGIN
insert into saved_indexes
select index_name,dbms_metadata.get_ddl('INDEX',index_name,v_owner)
from sys.all_indexes
where owner = v_owner
and table_name = v_table;
commit;
EXCEPTION
WHEN others THEN
v_errorcode := sqlcode;
v_errortext := substr(sqlerrm, 1, 1000);
dbms_output.put_line(v_errortext || ' ' || v_errorcode);
END;
Alternatively I have tried it this way:
PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2 ) IS
v_errorcode number(8);
v_errortext varchar2(1000);
v_index_ddl CLOB;
BEGIN
for x in (select index_name
from sys.all_indexes
where owner = v_owner
and table_name = v_table)
loop
select dbms_metadata.get_ddl('INDEX',x.index_name,v_owner) into v_index_ddl from dual;
insert into saved_indexes
values(v_table,v_index_ddl);
end loop;
commit;
EXCEPTION
WHEN others THEN
v_errorcode := sqlcode;
v_errortext := substr(sqlerrm, 1, 1000);
dbms_output.put_line(v_errortext || ' ' || v_errorcode);
END;
Always with the same result. I have poured over the documentation on this and have not found anything. All objects are in the same schema, so there is not an issues with invokers rights, or privileges.
Any suggestions would be helpful...qwe11126 wrote:
When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.There is nothing wrong with SP. Post a snippet of SQL*Plus code showing how you call SP along with errors.
SY. -
Calling DBMS_METADATA.GET_DDL on scheduler jobs owned by SYS
Hi!
While I can generally retrieve the DDL for scheduler jobs using the PROCOBJ type, this doesn't seem to work for scheduler jobs owned by SYS.
Does anybody happen to have a workaround for this?
SELECT user FROM dual
USER
SYS
1 row selected
select * from v$version
BANNER
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
5 rows selected
SELECT DBMS_METADATA.GET_DDL('PROCOBJ' ,'MGMT_CONFIG_JOB', 'ORACLE_OCM') DDL FROM dual
DDL
BEGIN dbms_scheduler.create_job( ...
1 row selected
SELECT DBMS_METADATA.GET_DDL('PROCOBJ' ,'AUTO_SPACE_ADVISOR_JOB', 'SYS') DDL FROM dual
ORA-31603: object "AUTO_SPACE_ADVISOR_JOB" of type PROCOBJ not found in schema "SYS"
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 1Cheers,
MarcusI guess I need SELECT_CATALOG_ROLE role
http://www.orafaq.com/node/807
SYS and users with SELECT_CATALOG_ROLE can see all objects. -
DBMS_METADATA.GET_DDL performance
Hi
My application need to run on a schema and get all the DDL of the schema objects.
This action is very heavy on the server and I get 100% on the server CPU.
my code look something like this:
SELECT
D.OBJECT_NAME,
D.OBJECT_TYPE,
TRIM(SYS.DBMS_METADATA.GET_DDL(REPLACE(REPLACE(OBJECT_TYPE,'DATABASE LINK','DB_LINK'),' ','_'),OBJECT_NAME,USER)) AS OBJECTCREATIONSCRIPT
FROM SYS.USER_OBJECTS D
INNER JOIN TEMPOBJECTSLIST OL
ON OL.DBOBJECT_NAME = D.OBJECT_NAME
AND OL.DBOBJECT_TYPE = D.OBJECT_TYPE
WHERE OBJECT_TYPE IN('TABLE', 'VIEW', 'FUNCTION', 'PROCEDURE', 'PACKAGE', 'PACKAGE BODY', 'SEQUENCE', 'TYPE', 'SYNONYM', 'MATERIALIZED VIEW', 'DATABASE LINK', 'TYPE BODY', 'TRIGGER')
Is ther any way to do this faster?
I was thinking on some ways but I do not know how to implement them:
1. working on paralel CPU - The action acording to Enterprise Manager is taking 100% of 1 of 4 CPUs.
2. Add some indexes or run statistics on some where in the database.
3. some other options...
thanksThanks, But I can't use an incremental table for this action becouse of some business logical restrictions of my application.
the application need to do the same action as GET_DDL for all the schema objects like one schema snapshot.
I have a new idea of solving this issue, perhaps someone could help me who to implement it (if it possible):
DMBS_METATDATA package has a procedure GET_XML this procedure is match faster than GET_DDL.
Is ther any way to convert the XML result of GET_XML to a DDL script?
Edited by: rronen on 00:06 01/09/2010
Edited by: rronen on 00:06 01/09/2010 -
DBMS_METADATA.GET_DDL inside the pl/sql procedure
We have a requirement to drop certain materialized view and need to recreate based on certain condition inside the
pl/sql procedure.i am using the dbms_metadata to get the Mv ddls.
var1 := 'SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW,'MV_NAME','OWNER')'|| 'from dual' || ';' ;
dbms_output.put_line(var1);
But i am unable to get the create ddl syntax in var1.
Can anyone help me on thisHi Deepu,
you are not helping us too much. You information are coming drop by drop.
Anyway, I don't have a materialized view but I have tried with a table.
Here is my test and output (what I expect you too show us too):
First test using normal SELECT FROM DUAL:
SET LONG 2000000
SET HEAD OFF
SET ECHO ON
SELECT DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS') FROM DUAL;
Output:
SQL>
SQL> SELECT DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS') FROM DUAL;
CREATE TABLE "SYS"."ALERT_QT"
( "Q_NAME" VARCHAR2(30),
"MSGID" RAW(16),
"CORRID" VARCHAR2(128),
"PRIORITY" NUMBER,
"STATE" NUMBER,
"DELAY" TIMESTAMP (6),
"EXPIRATION" NUMBER,
"TIME_MANAGER_INFO" TIMESTAMP (6),
"LOCAL_ORDER_NO" NUMBER,
"CHAIN_NO" NUMBER,
"CSCN" NUMBER,
"DSCN" NUMBER,
"ENQ_TIME" TIMESTAMP (6),
"ENQ_UID" VARCHAR2(30),
"ENQ_TID" VARCHAR2(30),
"DEQ_TIME" TIMESTAMP (6),
"DEQ_UID" VARCHAR2(30),
"DEQ_TID" VARCHAR2(30),
"RETRY_COUNT" NUMBER,
"EXCEPTION_QSCHEMA" VARCHAR2(30),
"EXCEPTION_QUEUE" VARCHAR2(30),
"STEP_NO" NUMBER,
"RECIPIENT_KEY" NUMBER,
"DEQUEUE_MSGID" RAW(16),
"SENDER_NAME" VARCHAR2(30),
"SENDER_ADDRESS" VARCHAR2(1024),
"SENDER_PROTOCOL" NUMBER,
"USER_DATA" "SYS"."ALERT_TYPE" ,
"USER_PROP" "SYS"."ANYDATA" ,
PRIMARY KEY ("MSGID")
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)
TABLESPACE "SYSAUX" ENABLE
) USAGE QUEUE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGIN
G
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSAUX"
OPAQUE TYPE "USER_PROP" STORE AS LOB (
ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
CACHE
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT))
{code}
Now with the procedure storing in CLOB variable
{code:sql}
SET SERVEROUTPUT ON SIZE UNLIMITED
SET LIN 5000
SET LONG 20000000
SET ECHO ON
DECLARE
l_clob CLOB;
BEGIN
l_clob := DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS');
DBMS_OUTPUT.put_line (l_clob);
END;
Output:
SQL>
SQL> DECLARE
2 l_clob CLOB;
3 BEGIN
4 l_clob := DBMS_METADATA.get_ddl ('TABLE', 'ALERT_QT', 'SYS');
5 DBMS_OUTPUT.put_line (l_clob);
6 END;
7 /
CREATE TABLE "SYS"."ALERT_QT"
( "Q_NAME" VARCHAR2(30),
"MSGID" RAW(16),
"CORRID" VARCHAR2(128),
"PRIORITY" NUMBER,
"STATE" NUMBER,
"DELAY" TIMESTAMP (6),
"EXPIRATION" NUMBER,
"TIME_MANAGER_INFO" TIMESTAMP (6),
"LOCAL_ORDER_NO" NUMBER,
"CHAIN_NO" NUMBER,
"CSCN" NUMBER,
"DSCN" NUMBER,
"ENQ_TIME" TIMESTAMP (6),
"ENQ_UID" VARCHAR2(30),
"ENQ_TID" VARCHAR2(30),
"DEQ_TIME" TIMESTAMP (6),
"DEQ_UID" VARCHAR2(30),
"DEQ_TID" VARCHAR2(30),
"RETRY_COUNT" NUMBER,
"EXCEPTION_QSCHEMA" VARCHAR2(30),
"EXCEPTION_QUEUE" VARCHAR2(30),
"STEP_NO" NUMBER,
"RECIPIENT_KEY" NUMBER,
"DEQUEUE_MSGID" RAW(16),
"SENDER_NAME" VARCHAR2(30),
"SENDER_ADDRESS" VARCHAR2(1024),
"SENDER_PROTOCOL" NUMBER,
"USER_DATA" "SYS"."ALERT_TYPE" ,
"USER_PROP" "SYS"."ANYDATA" ,
PRIMARY KEY ("MSGID")
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)
TABLESPACE "SYSAUX" ENABLE
) USAGE QUEUE 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 "SYSAUX"
OPAQUE TYPE "USER_PROP" STORE AS LOB (
ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
CACHE
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT))
{code}
It should be nice if you could post your tests too if they are not working.
Regards.
Al -
DBMS_METADATA.get_ddl issues
When you run, select dbms_metadata.get_ddl('USER', 'scott') FROM DUAL; gives following error...
ORA-31603: object "scott" of type USER not found in schema "SYSTEM"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 2805
ORA-06512: at "SYS.DBMS_METADATA", line 4333
ORA-06512: at line 1
But this works...
select dbms_metadata.get_ddl('USER', UPPER('scott')) FROM DUAL ;
This gives result..
DBMS_METADATA.GET_DDL('USER',U
CREATE USER "SCOTT" IDENTIFIED BY VALUES 'F894844C34402B67'
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
PASSWORD EXPIRE
ACCOUNT LOCK
I think the supplied object_name is case-sensitive. but why is it so.SQL> create user new_user identified by pwd;
User created.
SQL> select dbms_metadata.get_ddl('USER','NEW_USER') from dual;
DBMS_METADATA.GET_DDL('USER','NEW_USER')
CREATE USER "NEW_USER" IDENTIFIED BY VALUES 'D1ADB54B2BC01B82'
TEMPORA
SQL> select dbms_metadata.get_ddl('USER','new_user') from dual;
ERROR:
ORA-31603: object "new_user" of type USER not found in schema "SYSADM"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 653
ORA-06512: at "SYS.DBMS_METADATA", line 1260
ORA-06512: at line 1
no rows selected
SQL> create user "new_user" identified by pwd;
User created.
SQL> select dbms_metadata.get_ddl('USER','new_user') from dual;
DBMS_METADATA.GET_DDL('USER','NEW_USER')
CREATE USER "new_user" IDENTIFIED BY VALUES 'D1ADB54B2BC01B82'
TEMPORAnew_user and "new_user" are two differents users.
Nicolas. -
Dbms_metadata.get_ddl wonder...
I'm in the middle of testing a export/import of one database -A - to another - B - (the why is a long, complicated and convoluted discussion of business rules). So I want to grab the ddl for A, in order to create the tablespaces for B prior to importing. Okay, I'll just use dbms_metadata.get_ddl in A, do some editing, and run it in B. No problem. Worked fine. But... when I ran the import, I ran into error after error complaining about space. ?? I look at the script some more and see that the tablespace its importing into is only 1 MB. Its currently 1.5 GB in database A. More poking around, and I fine a difference between the script created with dbms_metadata.get_dd and one I've extracted from Enterprise Manager.
dbms_metadata.get_dd:
CREATE TABLESPACE "PTTBL" DATAFILE
'/oradata/DBATST/data1/pttbl01.dbf' SIZE 1114112
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT MANUAL
EM:
CREATE TABLESPACE "PTTBL"
LOGGING
DATAFILE '/oradata/HSCPY/data1/pttbl01.dbf' SIZE 2000M REUSE
AUTOEXTEND
ON NEXT 51200K MAXSIZE 3000M EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT MANUAL
Why the difference? I'm sure I'm missing something obvious, but I've been searching for an answer for this for quite a while.
Thanks,
Hal...here you go...
13:00:46 hscpy.system> select * from DBA_TABLESPACES where tablespace_name = 'PTTBL';
TABLESPACE_NAME BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE MIN_EXTLEN STATUS CONTENTS LOGGING FOR EXTENT_MAN ALLOCATIO PLU SEGMEN DEF_TAB_
RETENTION BIG
PTTBL 8192 65536 1 2147483645 65536 ONLINE PERMANENT LOGGING NO LOCAL SYSTEM NO MANUAL DISABLED
NOT APPLY NO
1 row selected.
13:00:48 hscpy.system> select * from DBA_DATA_FILES where tablespace_name = 'PTTBL';
FILE_NAME
FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
/oradata/HSCPY/data1/pttbl01.dbf
102 PTTBL 2097152000 256000 AVAILABLE 102 YES 3145728000 384000 6400 2097086464 255992
1 row selected.
Yes, its a PeopleSoft database, and its not 1 MB in our "running" version. ;-) I've also looked more closely at the script I created with my incredibly complex script (select 'select dbms_metadata.get_ddl(''TABLESPACE'',''' || tablespace_name || ''') from dual;' from dba_tablespaces;) and am seeing more than a few with SIZE 1114112.
I am running it in the same version of sqlplus. I've set my Oracle environment (with oraenv) to this HSCPY environment and use sqlplus from the same Oracle Home.
Thanks,
Hal... -
Dbms_metadata.get_ddl and lob columns
Good day, all,
I get the disappointing results, below, when trying to use the 9i dbms_metadata browsing package against a table with a BLOB (or CLOB) column. In other cases, it works fine; so I believe that it is not a "setup" or security problem.
Do you know any magic to get this to work?
Thanks!
Don M.
SQL> create table x (c1 blob);
Table created.
SQL> select dbms_metadata.get_ddl ('TABLE','X','DMAIER') from dual;
ERROR:
ORA-19206: Invalid value for query or REF CURSOR parameter
ORA-06512: at "SYS.DBMS_XMLGEN", line 83
ORA-06512: at "SYS.DBMS_METADATA", line 345
ORA-06512: at "SYS.DBMS_METADATA", line 410
ORA-06512: at "SYS.DBMS_METADATA", line 449
ORA-06512: at "SYS.DBMS_METADATA", line 615
ORA-06512: at "SYS.DBMS_METADATA", line 1221
ORA-06512: at line 1I have gone through some errors with invalid XDB objects when wanted to run dbms_metadata.get_ddl too. That was on 10gR2 (10.2.0.1 - though other instance was installed in "same" manner and everything worked ok). I had to drop and recreate XDK objects again - following some metalink note - I have posted the exact steps on metalink, I think I ran following commands from $ORACLE_HOME/RDBMS/ADMIN
catnomta.sql
catnodp.sql
rmxml.sql
catxml.sql
utlcxml.sql
prvtcxml.plb
catnomta.sql
dbmsmeta.sql
dbmsmeti.sql
dbmsmetu.sql
catemeta.sql
prvtmeta.plb
prvtmeti.plb
prvtmetu.plb
initmeta.sql
catdph.sql
catdpb.sql
initmeta.sql -
Getting table script using dbms_metadata.get_ddl, but with clob field
So, Oracle 11g R2..
I'm using dbms_metadata.get_ddl to get table scripts and it's working fine..
now, I have a table with clob field, and it's not working... I got an 'missing right parenthesis (ora-0907)' error...
I could paste a script that I got, but I don't think it makes any sense..
does anybody have some experience on using this package on clob tables?
tnxthis is script that I got... it's long, and it looks like it's not good
CREATE TABLE "COMMON"."TEST_AAA2"
( "ID" NUMBER(10,0),
"TEKST" VARCHAR2(200 CHAR),
"UPDATESTAMP" DATE,
"OBJEKAT" CLOB,
CONSTRAINT "TEST_PART_PK2" PRIMARY KEY ("ID")
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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
ALTER INDEX "COMMON"."TEST_PART_PK2" UNUSABLE ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
PARTITION BY RANGE ("UPDATESTAMP")
(PARTITION "P_201012" VALUES LESS THAN (TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201101" VALUES LESS THAN (TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201102" VALUES LESS THAN (TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201103" VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201104" VALUES LESS THAN (TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201105" VALUES LESS THAN (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201106" VALUES LESS THAN (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201107" VALUES LESS THAN (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_MAXVALUE" VALUES LESS THAN (MAXVALUE)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ) -
Hi,
I'm trying to extract schema DDL from a database (10.2.0.4.0 - 64bit Enterprise Edition on Solaris 10). I run the query below and get an ORA-00907: missing right parenthesis error.
SELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN ('TABLE_PARTITION','INDEX_PARTITION','LOB');
This is the output when running the above in sqlplus worksheet
select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects where object_type not in ('TABLE_PARTITION','INDEX_PARTITION','LOB')
ERROR at line 1:
ORA-00907: missing right parenthesis
removing the where clause gives the following:
select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects
ERROR at line 1:
ORA-00907: missing right parenthesis
Any pointers would be gratefully received. I know I could get the DDL out using exp/imp but I want to understand why I'm getting the missing parenthesis error.
cheers,
EwanSELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN You don't need an alias here. Get rid of " AS object_type" and it should work.
Maybe you are looking for
-
Nokia Lumia 1520 not finding Bluetooth headsets
Hello I have a nokia Lumia 1520 and it won't connect to the two bluetooth headsets I have. They are not even showing up to connect to. I tried with a Microsoft Xbox 360 Wireless Headset (bluetooth version 3.0) and a Sony MBH10 (bluetooth version 1.2
-
7410 All In One will not connect
I have a 7410 All In One. It's about 3 years old. Within the last 6 months it has been manifesting an ongoing problem. When not in use for a period of time, it will simply stop functioning. Upon disconnecting-reconnecting the power cord, the cent
-
Weblogic Integration 2.1 problem
<b>I have installed Oracle 9.X then installed Weblogic 6.1 and then installed Weblogic Integration 2.1 after instalation i have started Weblogic server by clicking wlintegration2.1/config/bpmDomain/startWeblogic.cmd Then i am getting this problem</b>
-
Wait class 'commit' consuming significant database time.
Hi My awr report was showing that the log file sync as the top wait event.I can also see additional message saying that wait class 'commit' consuming significant database time.Can any one suggest me what are the tuning things i need to consider for t
-
Windows xp home edition works program does not sync contacts with ipod
I recently purchased a new computer with the Windows XP Home edition and it had a new program called Works installed. It takes the place of excel, powerpoint, calender, outlook, etc. Started to add contacts and my iPod 30gb says it can't sync contact