GET_DDL function
Dear friends,
I could not find the reason for below query is not executed for EMP table,
whereas other tables are shown perfectly.
SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual;
ERROR:
ORA-31603: object "EMP" of type TABLE not found in schema "SCOTT"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 626
ORA-06512: at "SYS.DBMS_METADATA", line 1205
ORA-06512: at line 1
no rows selected
SQL> desc 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 object_type, owner, object_name
2 from all_objects where object_name='EMP';
OBJECT_TYPE OWNER OBJECT_NAME
TABLE SCOTT EMP
TABLE JAMES EMP
TABLE SCOT EMP
TABLE SHAMS EMP
SQL> select dbms_metadata.get_ddl('TABLE','EMP','SHAMS') from dual;
DBMS_METADATA.GET_DDL('TABLE','EMP','SHAMS')
CREATE TABLE "SHAMS"."EMP"
( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
"ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0),
PRIMARY KEY ("EMPNO")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCRE
ASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "JAMES_TS" ENAB
LE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCRE
ASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "JAMES_TS"
SQL> select dbms_metadata.get_ddl('TABLE','EMP','JAMES') from dual;
ERROR:
ORA-31603: object "EMP" of type TABLE not found in schema "JAMES"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 626
ORA-06512: at "SYS.DBMS_METADATA", line 1205
ORA-06512: at line 1
no rows selected
Similar Messages
-
Spool Command with dbms_metadata.GET_DDL function
Hi All,
My requirement is before applying a patch on the Database Schema, I need to take a backup of the db objects DDL script, so that incase if I want to rollback I can use it. what I am trying to use is the dbms_metadata.GET_DDL function to get the DDL script and with the help of spool command store that in a text file.
The problem I am encountering is the whole script runs without an error but whne I check the spool file for certain big packages the DDL script is not fully exported. The below is the script that I make use of to generate the DDL script.
set heading off
set feedback off
set echo off
set term off
set newpage none
set space 0
set trimout on
set TRIMSPOOL ON
column c1 format a4000
set long 99999
set lines 1000
exec DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', true);
spool c:\Rollback.sql
select dbms_metadata.GET_DDL('FUNCTION',u.object_name) || '/' c1
from user_objects u
where object_type = 'FUNCTION'
and object_name in ('FN_CALCMASTERDATA_AGE','FUNC_ASSIGNBENEFITSNONFLEX','FUNC_CHECKNEWEMPLOYEE');
select dbms_metadata.GET_DDL('PACKAGE_SPEC',u.object_name) || '/' c1
from user_objects u
where object_type = 'PACKAGE'
and object_name in('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST');
select dbms_metadata.GET_DDL('PACKAGE_BODY',u.object_name) || '/' c1
from user_objects u
where object_type = 'PACKAGE'
and object_name in ('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST','PKGT_FLEX_INITIALIZATION','PKGT_EMP');
spool off
Note: Database Oracle 10 g,
Client Machine Windows XP from where the script is ran.
Is there any limitation in amount of data that can be spooled? or is there is any better way to accomplish this task, please help.
Thanks
Saamiset long longer ;-)
set long 1000000 longchunksize 1000000 linesize 32000 pagesize 0 -
DBMS_METADATA.GET_DDL doesn't include function parameters
Sometimes, when I call DBMS_METADATA.GET_DDL to get the DDL statement for a function (which we always do to ensure we're starting from the source that's actually in production), the returned text doesn't include the parameters. Other times, it does, and I'm not able to see any pattern.
I was going to just make a function and show the output, but that did show the parameters. Then I tried calling GET_DDL while logged in as SYS as SYSDBA on my development database, and I still did not get the parameters, so I don't think it's a permissions issue.
Does anyone have any idea what's going on here?It's really difficult to show you exactly what I'm doing when I can't consistently reproduce the problem, as I described.
But here, I'll try.
declare
the_ddl clob;
begin
the_ddl := dbms_metadata.get_ddl('FUNCTION', '*****', '*****');
dbms_output.enable(null);
dbms_output.put_line(the_ddl);
end;
/Sometimes, it produces output like this:
CREATE OR REPLACE FUNCTION "*****"."*****" (
***** in varchar2,
***** in number,
) return *****
...And other times, it produces output like this:
CREATE OR REPLACE FUNCTION "*****"."*****" return *****
...I am not able to determine any consistent reason for this. In our production database, I can log in as myself and get the parameters for a specific function, but another user (that our automated process uses) doesn't see the parameters. In my development database, I log in as myself and I do not see the parameters, but I still don't see them when I log in as SYS AS SYSDBA.
For what it's worth, if I recreate the function on my development database, then subsequent calls do show the parameters. -
DBMS_METADATA.GET_DDL and Materialized View
hi gurus,
In 10gR2, i have created a materialized view EMP_MV with a simple structure.
I wanted to get the DDL of EMP_MV.
I used DBMS_METADATA to get the DDL,
select DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET') into v_return from dual;
Output
CREATE MATERIALIZED VIEW "TARGET"."EMP_MV"
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 "TARGET_TS_01"
BUILD IMMEDIATE
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 "TARGET_TS_01"
REFRESH FAST ON DEMAND
WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS select empid,empname,address from web.emp
Is there any way to get only SELECT part of this MV, ie select empid,empname,address from web.emp directly from dictionary without any string manipulation?
tia,
newbieYes you can do it. By using INSTR and SUBTR against the result of GET_DDL function
Try this:
select substr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),instr(DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','EMP_MV','TARGET'),'select'),1000)
into v_return from dual;- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
Dbms_metadata.get_ddl returns unusable create index statement
Hello everybody,
I'm trying to write a procdeure that automatically deletes all duplicate record and rebuild all table indexes after an sqlldr load with direct path.
In short the procdeure indentifies the indexes, read them using dbms_metadata.get_ddl('INDEX', 'IDX_UNIQUE_TEST') drops them, deletes the duplicated records and then recreates the indexes.
However after the sqlldr, get_ddl function returns the following result:
CREATE UNIQUE INDEX "MYUSER"."IDX_UNIQUE_TEST" ON "EDWH"."FOREX_ORD_PRC_INTRADAY" "C_ORD_TYP", "C_ORD", "D_INI_VAL", "C_PRC_TYP")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 131072 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "MYTABLESPACE"
ALTER INDEX "MYUSER"."IDX_UNIQUE_TEST" UNUSABLE
As you can see there is an ALTER INDEX at the end that makes the whole statement invalid.
Has anyone already seen that? I've tried to google it but with no chance. Help with this would really be appreciated.
Thanks in advance
RossMmh, yes it is unusable before the get_ddl, but how comes it returns both the create index and the alter index unusable statements?
I've tried to make the index unusable with the alter index ... unusable statement but get_ddl still returned the create index only.
I'm guessing that production server (10.2.0.4.0) is behaving differently from test machine (9.2.0.4.0). Any idea on that?
Ross -
Bug in DBMS_METADATA.get_ddl?
If you create the functions:
CREATE OR REPLACE FUNCTION testingit1 RETURN NUMBER IS
tmpVar NUMBER;
BEGIN
tmpVar := 0;
RETURN tmpVar;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END testingit1;
and
CREATE OR REPLACE FUNCTION
testingit2 RETURN NUMBER IS
tmpVar NUMBER;
BEGIN
tmpVar := 0;
RETURN tmpVar;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END testingit2;
And use DBMS_METADATA.get_ddl to return the code. When the function was created with the name on a seperate line (testingit2) the code returned has the name repeated
e..g., SELECT DBMS_METADATA.get_ddl('FUNCTION', 'TESTINGIT2')
FROM dual
returns
"CREATE OR REPLACE FUNCTION "TESTUSER"."TESTINGIT2"
testingit2 RETURN NUMBER IS
tmpVar NUMBER; ..."
Anyone seen this before and know how to fix it?using some sort of XML transform? Yes,
SQL> create or replace function get_code return clob is
2 l_xml XMLTYPE ;
3 l_xsl XMLTYPE ;
4 begin
5 select XMLTYPE(dbms_metadata.get_xml('FUNCTION', 'TESTINGIT2')) into l_xml from dual ;
6 l_xsl := XMLTYPE('<?xml version="1.0"?>'||
7 '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'||
8 ' version="1.0"'||
9 ' result-ns=""'||
10 ' indent="no">'||
11 '<xsl:output method="text" media-type="text/text" indent="no"/>'||
12 '<xsl:template match="/">'||
13 'CREATE OR REPLACE <xsl:for-each select="//SOURCE_LINES/SOURCE_LINES_ITEM">'||
14 '<xsl:value-of select="./SOURCE" />'||
15 ' </xsl:for-each>'||
16 '</xsl:template>'||
17 '</xsl:stylesheet>') ;
18 return(l_xml.transform(l_xsl).getCLOBVal()) ;
19 end ;
20 /
Function created.
SQL> select get_code from dual ;
GET_CODE
CREATE OR REPLACE FUNCTION
testingit2 RETURN NUMBER IS
tmpVar NUMBER;
begin
null ;
end ;
1 row selected.
SQL> -
Get_ddl Not giving the entire DDL
Hi,
SQL> select dbms_metadata.get_ddl('TABLE','CS_CSG_SYSTEMS') from dual;
DBMS_METADATA.GET_DDL('TABLE','CS_CSG_SYSTEMS')
CREATE TABLE "CUSTSRV"."CS_CSG_SYSTEMS"
( "RECORD_NO" NUMBER(15,0),
"SY
SQL> desc cs_csg_systems;
Name Null? Type
RECORD_NO NOT NULL NUMBER(15)
SYSTEM_NO NUMBER(15)
APP_TYPE VARCHAR2(20)
SUB_APP_TYPE VARCHAR2(20)
INCLUDE_FLAG NUMBER(1)
PRIN_NO NUMBER(4)Why is the get_ddl function not giving the entire ddl ?
Thanks
RajivI think this is it ?
SQL> set long 2000
SQL> select dbms_metadata.get_ddl('TABLE','CS_CSG_SYSTEMS') from dual;
DBMS_METADATA.GET_DDL('TABLE','CS_CSG_SYSTEMS')
CREATE TABLE "CUSTSRV"."CS_CSG_SYSTEMS"
( "RECORD_NO" NUMBER(15,0),
"SYSTEM_NO" NUMBER(15,0),
"APP_TYPE" VARCHAR2(20),
"SUB_APP_TYPE" VARCHAR2(20),
"INCLUDE_FLAG" NUMBER(1,0),
"PRIN_NO" NUMBER(4,0),
CONSTRAINT "CS_CSG_SYSTEMS_PK" PRIMARY KEY ("RECORD_NO")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 524288 NEXT 524288 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CUST_SML_X" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "CUST_SML_D" -
Pre condition functions export
I have another question.
I have tried to export pre conditions but have not succeed yet in exporting the Pre Condition functions.
The jcs_describe.describe doesn't work with the following types 'PRE_CONDITION', 'PRECONDITION', 'FUNCTION', etc.
Since it is possible to export the object on the RWE, with right-click / export, we guess that it is somehow possible with PL SQL functions.
Can someone give me some clues about that ?
Thanks again for your help,
Regards,
Yi JiangHi,
Preconditions are not described like chains, scripts etc. They are regular functions in the database, which can be described using standard database functions.
As an example (in the Redwood Shell):
set serveroutput on
spool [youroutputfile].sql
declare
c clob;
begin
c:= dbms_metadata.get_ddl ( 'FUNCTION', '[functionname]', '[functionowner]' );
dbms_output.put_line ( c );
end;
spool off
set serveroutput off
This will give you the definition of your precondition function in a file (of course you need to replace the texts between \[\] with proper values applying to your environment.
You can put this in a single script, let's call it desc_function.sql and pass the owner and functionname as parameters. From the Redwood Shell, the call would look like this:
@desc_function [owner] [functionname]
The file desc_function.sql would contain the following text:
set serveroutput on
spool &1._&2..sql
declare
c clob;
begin
c:= dbms_metadata.get_ddl ( 'FUNCTION', '&2', '&1' );
dbms_output.put_line ( c );
end;
spool off
set serveroutput off
Hope this helps you out.
Kind regards,
Anton Goselink -
How to know the packages,functions,triggers owned by schema
I got the script to find the tables,columns and indexes belonged to a schema
how to find the packages,functions triggers owned by a schema.
I need to compare schema of PROD with UAT
Any help will be appreciatedis it possible to find the source of all those
objects in a single scriptWhat do you mean?
user_source will give the script?Yes.
You can get script more easily with DBMS_METADATA
SQL> drop FUNCTION "HR"."F11";
Function dropped.
SQL> CREATE OR REPLACE FUNCTION "HR"."F11" return varchar2
as
v_date varchar2(1000);
begin
select to_char(sysdate,'mmddyyyy') into v_date from dual;
return v_date;
end; 2 3 4 5 6 7
8 /
Function created.
SQL> set pagesize 0
SQL> set long 90000
SQL> select DBMS_METADATA.GET_DDL (
'FUNCTION',
object_name,
'HR')
FROM all_objects
WHERE owner = 'HR'
AND object_type ='FUNCTION' 3 4 5 6 7
8 /
CREATE OR REPLACE FUNCTION "HR"."F11" return varchar2
as
v_date varchar2(1000);
begin
select to_char(sysdate,'mmddyyyy') into v_date from dual;
return v_date;
end;
Is there any script to identify source for all those
objects -
Spoolling output of CLOBs from GET_DDL().
Hi,
In both dos command window and puTTY on AIX, I can't seem to get my spooled output to not wrap at 80 characters. It's driving me nutz.
set pagesize 0
set linesize 10000
set trim on
set trimspool on
SET LONG 32000
spool tts_ddl.sql
SELECT trim(DBMS_METADATA.GET_DDL(object_type, object_name, owner)) || ';'
FROM DBA_OBJECTS
WHERE OBJECT_TYPE in ('SEQUENCE')
AND OWNER = 'FPPS'
ORDER BY OBJECT_TYPE;
spool off;
exit;
Any help would be really appreciated.
Thanks.
brianHi guys,
Will try your two suggestions in the morning.
It may not have anything to do with CLOBS. I'm trying to create ddl from the GET_DDL function but my output is always like this.
And of course the wrap at where it is, the command will fail when I try to run it.
CREATE SEQUENCE "FPPS"."JOURNAL_ENTRY_SUMRY_S" MINVALUE 1000 MAXVALUE 99999
9999999 INCREMENT BY 1 START WITH 110053 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."FINANCIAL_CONTROL_S" MINVALUE 1000 MAXVALUE 9999999
99999 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."DISBURSEMENT_BATCH_NUMBER_S" MINVALUE 1250 MAXVALUE
999999999999 INCREMENT BY 1 START WITH 4023 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."CHEQUE_NUM_S" MINVALUE 750000 MAXVALUE 999999999999
INCREMENT BY 1 START WITH 1039810 NOCACHE NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."FINANCIAL_BATCH_DISBURSEMENT_S" MINVALUE 1000 MAXVA
LUE 999999999999 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."BANK_CHEQUE_S" MINVALUE 1000 MAXVALUE 999999999999
INCREMENT BY 1 START WITH 266703 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."ELECTRONIC_FUND_TRNSFR_INFO_S" MINVALUE 1000 MAXVAL
UE 999999999999 INCREMENT BY 1 START WITH 23037 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."TEMP_POOL_RATE_STORE_S" MINVALUE 1000 MAXVALUE 9999
99999999 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER NOCYCLE
CREATE SEQUENCE "FPPS"."TST_RECEIPT_ADD_S" MINVALUE 1000 MAXVALUE 999999999
999 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER NOCYCLE
; -
Export Procedure,Function
Hi all,
I have oracle 10g on winodws 2000.
I want to know that is it possible to take only procedure and function Dumpfile from schema.
So that i can import that procedure and Function on production.
Thanks,
Neerav
Edited by: Neerav999 on Jan 20, 2010 3:34 PMHi,
You can create the dml using dbms_metadata.get_ddl function and spool it in a file
eg
spool exp_proc.sql
select dbms_metadata.get_ddl(OBJECT_TYPE,OBJECT_NAME,OWNER)
from dba_objects
where owner in ('<LIST of owner you want to export>')
and object_type in ('LIST of object type you want to export>')
spool offRegards
Anurag -
Select text from all_views returns an empty string
My application allows the user to select between the Data Provider for ODBC and the Data Provider for Oracle. (ODP)
When using the ODBC provider the statement:
Select text from all_views where view_name='MYVIEW'
returns the expected string.
If I connect via ODP however it returns an empty string.
(If I use 'Select *' it tells me the text_length is 154 in this specific case - so there is definately text available.)
I'm thinking it has something to do with the fact that the data type is LONG.
In both cases I retreive the data using rdr.GetChars(), which should work.
If I use the dbms_metadata.get_ddl function instead, it does return the string (Probably because the return type is not LONG)
Unfortunately that function only works for Views in the current schema, while the original Select works for any view.
(And I dont know what version of Oracle this function was added in - I have to support older versions too.)
Similarly, if I use one of the XML functions to retreive the text as XML it works fine.
(Again it is probably returned as a VARCHAR2 instead of a LONG.)
The strange thing is that when I created my own table containing a LONG column I was able to load and retreive data without any problems.
The problem appears to be specific to this column in all_views.
Anyone know a solution to this?
Thanks
MikeThanks that was it.
I had not seen those properties since I am working with the 'generic' objects (DbCommand rather than OracleCommand, etc.)
What is strange is that I was able to retreive data from my own LONG column WITHOUT setting this value to -1.
(It defaulted to 0 in both cases.)
The only difference was that when I retreived data from my own column I specified CommandBehaviour.SequentialAccess.
When I retreived the all_views.text column I did not specify a behaviour at all.
However the Oracle docs said that SequentialAccess is not supported ... so I guess that is not correct.
(Maybe it doesn't 'work', but it certainly seems to cause things to work differently)
Thanks
Mike -
How can i get the SQL of a tablespace from the database
Hello All,
I am using Oracle 11g R2. I want to get the SQL of some tablespaces on my database. in the same way i get the DDL of the table using the GET_DDL function.
How can i get that ?
Regards,try this please
select dbms_metadata.get_ddl('TABLESPACE',tb.tablespace_name) from dba_tablespaces tb;or
select 'create tablespace ' || df.tablespace_name || chr(10)
|| ' datafile ''' || df.file_name || ''' size ' || df.bytes
|| decode(autoextensible,'N',null, chr(10) || ' autoextend on maxsize '
|| maxbytes)
|| chr(10)
|| 'default storage ( initial ' || initial_extent
|| decode (next_extent, null, null, ' next ' || next_extent )
|| ' minextents ' || min_extents
|| ' maxextents ' || decode(max_extents,'2147483645','unlimited',max_extents)
|| ') ;'
from dba_data_files df, dba_tablespaces t
where df.tablespace_name=t.tablespace_name Edited by: Mahir M. Quluzade on Mar 14, 2011 4:51 PM -
To get rid of Schema name in output using DBMS_METADATA
Hi all,
Would someone be able to tell me how to get rid of the schema name output given by the below select stmt.
Query
Select Dbms_metadata.Get_ddl('FUNCTION','ACCOUNT_CODE')
from dual;
Result
CREATE OR REPLACE FUNCTION "GOINGLIVE"."ACCOUNT_CODE" (PTransCode VarChar2,.............
I checked for the documentation, but could manage to eliminate only storage clauses, tablespace etc. but not teh schema name.
Please provide your advise on this.
Thanks
- SandeepWhich version are you on?
In 10g, you can use DBMS_METADATA.SET_REMAP_PARAM to get rid of schema name:
SQL> create table md_test(x int, y varchar2(10));
Table created.
SQL> declare
2 l_ctx number;
3 l_ctxt number;
4 l_ddl sys.ku$_ddls;
5 begin
6 l_ctx := dbms_metadata.open('TABLE');
7 dbms_metadata.set_filter(l_ctx, 'NAME', 'MD_TEST');
8 l_ctxt := dbms_metadata.add_transform(l_ctx, 'MODIFY');
9 dbms_metadata.set_remap_param(l_ctxt, 'REMAP_SCHEMA', user, null);
10 l_ctxt := dbms_metadata.add_transform(l_ctx, 'DDL');
11 dbms_metadata.set_transform_param(l_ctxt, 'SEGMENT_ATTRIBUTES', false);
12 l_ddl := dbms_metadata.fetch_ddl(l_ctx);
13 dbms_output.put_line(l_ddl(1).ddltext);
14 dbms_metadata.close(l_ctx);
15 end;
16 /
CREATE TABLE "MD_TEST"
( "X" NUMBER(*,0),
"Y" VARCHAR2(10)
PL/SQL procedure successfully completed.In 9i, you have to resort to some manual tricks (with REPLACE, probably):
SQL> create table md_test(x int, y varchar2(10));
Table created.
SQL> declare
2 l_ctx number;
3 l_ctxt number;
4 l_ddl sys.ku$_ddls;
5 begin
6 l_ctx := dbms_metadata.open('TABLE');
7 dbms_metadata.set_filter(l_ctx, 'NAME', 'MD_TEST');
8 l_ctxt := dbms_metadata.add_transform(l_ctx, 'DDL');
9 dbms_metadata.set_transform_param(l_ctxt, 'SEGMENT_ATTRIBUTES', false);
10 l_ddl := dbms_metadata.fetch_ddl(l_ctx);
11 dbms_output.put_line(
12 replace(l_ddl(1).ddltext, '"' || user || '".'));
13 dbms_metadata.close(l_ctx);
14 end;
15 /
CREATE TABLE "MD_TEST"
( "X" NUMBER(*,0),
"Y" VARCHAR2(10)
PL/SQL procedure successfully completed.
SQL> select * from v$version where rownum = 1;
BANNER
Oracle9i Enterprise Edition Release 9.2.0.6.0 - ProductionHope this helps,
Andrew. -
Hi All,
I encountered a strange problem when I was doing an export from a 10.2.0.3 on solaris to a 10.2.0.3 databsae on another solaris box.
expdp system dumpfile=db_20100617.dmp logfile=db_20100617.log directory=expdp full=y compression=metadata_only parallel=2 status=30
and this is my import statement
impdp system dumpfile=db_20100617.dmp logfile=db_20100617_imp.log directory=expdp full=y parallel=4
I've followed this process twice, and everytime on my destination database, all my columns with (source) data_type=TIMESTAMP(6) woudl be converted to data_type=TIMESTAMP(0) which causes a select that defines the column name (select column1 from tablea) to crash with a End-of-communication error.
Fortunately, the work around was to alter table modify column and set it to timestamp(6), but I was wondering if anyone else had seen this before. My log shows no errors with table creation, only issues package compilation and dblinks.
Has anyone seen this problem before or know how to bypass it?Hi All,
Just to finish off this thread. I've put it through metalink and they havne't confirmed it as a bug. Their only resolution according to oracle support was to recreate the table manually. Because any table created using
create table ... as select *
also causes the issue during an export stage. Using the get_ddl function also produces the same error with timestamp(0).
Anyway all, thanks for your time.
Cheers.
Maybe you are looking for
-
I had a problem with my List Cube Transaction and for that reason, I had a look at the Infoprovider and also the Data Sources. When tried to execute the infoproviders in LISTCUBE, the following messages are being displayed in BWT system: 1. Error rea
-
Hi, I am using XSLT to generate a webpage using an XML file and a stylesheet. The HTML page is created fine however any HTML tag i.e. the break line tag comes out in the file as <.;BR>.; rather then <.BR.> (ignore the dots, just there so the form
-
Well it is said that for the specs of the 3rd gen nano (8GB) that you can have Up to 2,000 songs, up to 7,000 photos, up to 8 hours of video, or some of each. What if I use around 2,000 Songs but no photos, how much more hours of video can i have?
-
Blocking display of material prices
Can we block display of material prices for some of the users? Either thru standard authorization object or config...and it should be available in all standard transactions like ME23N, MM03 etc. The exact business requirement is - Not to display all
-
IPV6 support by SAP Java Connector (SAP JCo)
Hi there, Does anyone know if IPV6 is supported by SAP Java Connector (SAP JCo) ? Thanks