How to get an Oracle sql text from a dmp file? - oracle
Can I get an actual sql definition from an Oracle dmp file? I'm trying to migrate a complete schema into another (not oracle) type of database and I want all the tables and views etc. so I can edit them in sql format. I have a .dmp of the whole thing, but can I get it in text format?
The Oracle imp command has a show parameter. From the Oracle 11.2 docs
SHOW
Default: n
When SHOW=y, the contents of the export dump file are listed to the display and not imported. The SQL statements contained in the export are displayed in the order in which Import will execute them.
The SHOW parameter can be used only with the FULL=y, FROMUSER, TOUSER, or TABLES parameter.
The impdp command has a sqlfile parameter. From the Oracle 11.2 docs
SQLFILE
Default: There is no default
Purpose
Specifies a file into which all of the SQL DDL that Import would have executed, based on other parameters, is written.
Syntax and Description
SQLFILE=[directory_object:]file_name
The file_name specifies where the import job will write the DDL that would be executed during the job. The SQL is not actually executed, and the target system remains unchanged. The file is written to the directory object specified in the DIRECTORY parameter, unless another directory_object is explicitly specified here. Any existing file that has a name matching the one specified with this parameter is overwritten.
Note that passwords are not included in the SQL file. For example, if a CONNECT statement is part of the DDL that was executed, then it will be replaced by a comment with only the schema name shown. In the following example, the dashes (--) indicate that a comment follows, and the hr schema name is shown, but not the password.
-- CONNECT hr
Therefore, before you can execute the SQL file, you must edit it by removing the dashes indicating a comment and adding the password for the hr schema.
For Streams and other Oracle database options, anonymous PL/SQL blocks may appear within the SQLFILE output. They should not be executed directly.
Restrictions
If SQLFILE is specified, then the CONTENT parameter is ignored if it is set to either ALL or DATA_ONLY.
To perform a Data Pump Import to a SQL file using Oracle Automatic Storage Management (Oracle ASM), the SQLFILE parameter that you specify must include a directory object that does not use the Oracle ASM + notation. That is, the SQL file must be written to a disk file, not into the Oracle ASM storage.
The SQLFILE parameter cannot be used in conjunction with the QUERY parameter.
Example
The following is an example of using the SQLFILE parameter. You can create the expfull.dmp dump file used in this example by running the example provided for the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
SQLFILE=dpump_dir2:expfull.sql
A SQL file named expfull.sql is written to dpump_dir2.
Here is the command line for imp
imp system#myinstance fromuser=myuser touser=user2 file=f:\mypath\mydmpfile.dmp show=y rows=n log=f:\mypath\mylogfile.log statistics=none buffer=2000000 feedback=1000
Here is some output in the .log file
Connected to: Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
Export file created by EXPORT:V10.02.01 via conventional path
Warning: the objects were exported by MYUSER, not by you
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing MYUSER's objects into MYNEWUSER
"BEGIN "
"sys.dbms_logrep_imp.instantiate_schema(schema_name=>SYS_CONTEXT('USERENV','"
"CURRENT_SCHEMA'), export_db_name=>'MYOLDUSER', inst_scn=>'623831137');"
"COMMIT; END;"
"CREATE DATABASE LINK "DATABASELINK1" CONNECT TO CURRENT_USER USING ''"
... and so on
"ALTER SESSION SET CURRENT_SCHEMA= "MYNEWUSER""
"CREATE TABLE "AD_HOC_TYPE" ("COLUMN_NAME" VARCHAR2(4000) NOT NULL ENABLE, ""
"AD_HOC_TYPE" NUMBER NOT NULL ENABLE, "VIEW_NAME" VARCHAR2(4000) NOT NULL EN"
"ABLE, "LOOKUP_TABLE" VARCHAR2(4000), "AD_HOC_TYPE_ID" NUMBER NOT NULL ENABL"
"E) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FRE"
"ELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "MYOLDTABLESPACE" LOGGI"
"NG NOCOMPRESS"
. . skipping table "AD_HOC_TYPE"
"CREATE UNIQUE INDEX "AD_HOC_TYPE_PK" ON "AD_HOC_TYPE" ("AD_HOC_TYPE_ID" ) "
"PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELI"
"ST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "MYOLDTABLESPACE" LOGGING"
"ALTER SESSION SET CURRENT_SCHEMA= "MYNEWUSER""
"ALTER TABLE "AD_HOC_TYPE" ADD CONSTRAINT "AD_HOC_TYPE_PK" PRIMARY KEY ("AD"
"_HOC_TYPE_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITI"
"AL 65536 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "MYOLDTABLESPACE"
"OLDUSER" LOGGING ENABLE "
... and so on
"ALTER TABLE "MOA_TYPE" ENABLE CONSTRAINT "MOA_TEXT_FK""
"ALTER TABLE "MOA_TEXT" ENABLE CONSTRAINT "CHRONIC_MOA_TEXT_FK""
Import terminated successfully without warnings.
Here is the command line for impdp
impdp myuser#myinstance DIRECTORY=exports DUMPFILE=table.dmp sqlfile=exports:sqlddl.sql logfile=exports:impdplog.log
Here is the logfile impdplog.log contents
;;;
Import: Release 11.2.0.3.0 - Production on Thu Jun 6 14:58:05 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
;;;
Connected to: Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
Master table "MYUSER"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "MYUSER"."SYS_SQL_FILE_FULL_01": MYUSER/********#dultest1 DIRECTORY=exports DUMPFILE=table.dmp sqlfile=exports:sqlddl.sql logfile=exports:impdplog.log
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "MYUSER"."SYS_SQL_FILE_FULL_01" successfully completed at 14:58:33
Here is the SQLFILE sqlddl.sql contents
-- CONNECT MYUSER
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: TABLE_EXPORT/TABLE/TABLE
CREATE TABLE "MYUSER"."SPERRORLOG"
( "USERNAME" VARCHAR2(256 BYTE),
"TIMESTAMP" TIMESTAMP (6),
"SCRIPT" VARCHAR2(1024 BYTE),
"IDENTIFIER" VARCHAR2(256 BYTE),
"MESSAGE" CLOB,
"STATEMENT" CLOB
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
LOB ("MESSAGE") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192
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))
LOB ("STATEMENT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192
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)) ;
-- new object type path: TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
DECLARE
c varchar2(60);
nv varchar2(1);
df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS';
s varchar2(60) := 'MYUSER';
t varchar2(60) := 'SPERRORLOG';
p varchar2(1);
sp varchar2(1);
stmt varchar2(300) := 'INSERT INTO "SYS"."IMPDP_STATS" (type,version,c1,c2,c3,c4,c5,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,d1,r1,r2,ch1,flags,cl1) VALUES (:1,6,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23)';
BEGIN
DELETE FROM "SYS"."IMPDP_STATS";
INSERT INTO "SYS"."IMPDP_STATS" (type,version,flags,c1,c2,c3,c5,n1,n2,n3,n4,n9,n10,n11,n12,d1) VALUES ('T',6,2,t,p,sp,s,
14,8,243,14,0,NULL,NULL,NULL,
TO_DATE('2012-12-13 22:00:14',df));
c := 'USERNAME';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
1,1,1,14,0,3.75311197656206E+35,3.75311197656206E+35,8,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),'4848454C47454E','4848454C47454E',nv,2,nv;
c := 'TIMESTAMP';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
10,.1,10,14,0,2456121.67056713,2456270.83032407,11,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),'7870070C110626','78700C08143829',nv,2,nv;
c := 'SCRIPT';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
0,0,0,nv,14,0,0,0,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),nv,nv,nv,2,nv;
c := 'IDENTIFIER';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
0,0,0,nv,14,0,0,0,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),nv,nv,nv,2,nv;
END;
/
DECLARE
c varchar2(60);
nv varchar2(1);
df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS';
s varchar2(60) := 'MYUSER';
t varchar2(60) := 'SPERRORLOG';
p varchar2(1);
sp varchar2(1);
stmt varchar2(300) := 'INSERT INTO "SYS"."IMPDP_STATS" (type,version,c1,c2,c3,c4,c5,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,d1,r1,r2,ch1,flags,cl1) VALUES (:1,6,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23)';
BEGIN
NULL;
c := 'MESSAGE';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
0,0,0,10,4,0,0,133,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),nv,nv,nv,2,nv;
c := 'STATEMENT';
EXECUTE IMMEDIATE stmt USING 'C',t,p,sp,c,s,
0,0,0,10,4,0,0,91,0,nv,nv,
TO_DATE('2012-12-13 22:00:14',df),nv,nv,nv,2,nv;
DBMS_STATS.IMPORT_TABLE_STATS('"MYUSER"','"SPERRORLOG"',NULL,'"IMPDP_STATS"',NULL,NULL,'"SYS"');
DELETE FROM "SYS"."IMPDP_STATS";
END;
/
Related
oracle saving non english characters not working via script
I have c# program that fills me database with values, but when I try to export them to import.sql and then run import.sql script it always fill database with special characters and not czech letters. Via example I have this table CREATE TABLE Document ( "Id" NUMBER(19,0) GENERATED BY DEFAULT ON NULL AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE , "name" NVARCHAR2(200), "fullname" NVARCHAR2(300) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ; and when I export data for example 1, "Velmi přívětivý dokument", "Dokument který byl velmi přívětivý do doby než SQL přeházelo písmenka" and insert inside import.sql looks like this CREATE TABLE Document ( "Id" NUMBER(19,0) GENERATED BY DEFAULT ON NULL AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE , "name" NVARCHAR2(200), "fullname" NVARCHAR2(300) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ; INSERT INTO Document ("Id","name","fullname") values (1, "Velmi přívětivý dokument", "Dokument který byl velmi přívětivý do doby než SQL přeházelo písmenka") and run script (Using dockerd to host local db) I get special characters like this 'p��v�iv�' instead 'Přívětivý' but when I run that INSERT inside SQL Developer it insert all czech characters inside db without any problem. I am not really sure where the problem is.
You must set encoding, a.k.a. "code page" of your terminal (I assume cmd.exe, but I don't know docker) to the encoding of your export file. The default is neither UTF-8, nor CP1250, nor CP1252. Most like it is CP437, CP850 or CP852 depending on your Windows language, see https://web.archive.org/web/20170916200715/http://www.microsoft.com/resources/msdn/goglobal/default.mspx You can interrogate and change it with command chcp Code Page Identifiers you can find here
Need to ignore "start with" sequence for identity column when comparing schema in oracle db
We have an oracle database (18c) on several servers, and need to sync the schema from dev to prod servers. Since it is only the schema that needs to be synced, and not the content of the tables, we do not need to know the next sequence number of primary key columns. (And we certainly do not want to update the prod servers with this sequence number.) Have tried both SQL Developers Diff Tool and dbForge Schema Compare for Oracle, but they both list tables where only this sequence number is different as tables that need to be updated. I have not found a setting in SQL Developer Diff Tool that handles this. In dbForge Schema Compare for Oracle they have the Ignore START WITH in sequences, but this seems to not work as I thought, since it still marks tables that are equal except for the sequence number as tables that need an update. For new tables that only exist in the source db - the sync script will be like this: CREATE TABLE TEST ( ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY( START WITH 102), TEXT VARCHAR2(4000 BYTE), CONSTRAINT TEST_ID_PK PRIMARY KEY (ID)) LOGGING; We need that script without the (START WITH 102) part in it. For a table that exist in both source and target db (with no other change than the sequence number) - the sync script will be like this: ALTER TABLE TEST MODIFY(ID GENERATED BY DEFAULT ON NULL AS IDENTITY( START WITH 114 INCREMENT BY 1 MAXVALUE 9999999999999999999999999999 MINVALUE 1 CACHE 20 NOCYCLE NOORDER)); The reality here is that this is a table that does not need an update, and I thought that Ignore START WITH in sequence would handle this, but apparently not. Anyone out there have a solution for us?
Well, I believe it is a very bad idea to use SQL Developer, or any other IDE tool for that matter, to create scripts to be deployed on Production. You are describing a clear case of lacking a real control version software, like GIT or SVN. You shouldn't need to compare between databases unless there is something wrong, but never for creating DDL scripts. In this specific case, I would use DBMS_METADATA to create the DDLs Example SQL> create table t ( c1 number generated by default on null as identity ( start with 1 increment by 1 ) , c2 number ) ; Table created. SQL> insert into t values ( null , 1 ) ; 1 row created. SQL> r 1* insert into t values ( null , 1 ) 1 row created. SQL> r 1* insert into t values ( null , 1 ) 1 row created. SQL> r 1* insert into t values ( null , 1 ) 1 row created. SQL> select * from t ; C1 C2 ---------- ---------- 1 1 2 1 3 1 4 1 In this case SQL developer shows start with 5, because that is the next value of the identity column. You can use DBMS_METADATA.GET_DDL to get the right DDL without this clause. SQL> begin DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); end; / PL/SQL procedure successfully completed. SQL> select dbms_metadata.get_ddl('TABLE','T') from dual DBMS_METADATA.GET_DDL('TABLE','T') -------------------------------------------------------------------------------- CREATE TABLE "SYS"."T" ( "C1" NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY MINVALUE 1 MAXVALUE 99 99999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE NOT NULL ENABLE, "C2" NUMBER ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SYSTEM" ; There are several options to for example not get the storage attributes. I always use this one SQL> BEGIN 2 DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true); DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true); 3 4 DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SEGMENT_ATTRIBUTES', true); DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'STORAGE', false); END; / 5 6 7 PL/SQL procedure successfully completed. SQL> select dbms_metadata.get_ddl('TABLE','T') from dual ; DBMS_METADATA.GET_DDL('TABLE','T') -------------------------------------------------------------------------------- CREATE TABLE "SYS"."T" ( "C1" NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY MINVALUE 1 MAXVALUE 99 99999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE NOT NULL ENABLE, "C2" NUMBER ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "SYSTEM" ; SQL> For comparison purposes, you might want to have a look into DBMS_COMPARISON https://docs.oracle.com/database/121/ARPLS/d_comparison.htm#ARPLS868
Get complete ddl for index in oracle
I am using oracle 11g/12c. I want to get ddl of indexes in my database. For this I used the query - SELECT DBMS_METADATA.GET_DDL('INDEX','SYS_IL0000091971C00001$$','CCEEXPERTS') FROM dual Here 'SYS_IL0000091971C00001$$' is my index name and 'CCEEXPERTS' is my owner name. From this I get the ddl - CREATE UNIQUE INDEX "CCEEXPERTS"."SYS_IL0000091971C00001$$" ON "CCEEXPERTS"."DATABLOB" ( And my actual ddl is - CREATE UNIQUE INDEX "CCEEXPERTS"."SYS_IL0000091971C00001$$" ON "CCEEXPERTS"."DATABLOB" ( 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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" PARALLEL (DEGREE 0 INSTANCES 0) ; In actual ddl after "CCEEXPERTS"."DATABLOB" ( , next line character and from their the ddl is truncted. How can I get the complete ddl? Please help me... Thanks in advance.
In SQLplus, set these before running the procedure. set long 100000 set longchunksize 100000
Oracle has a DBMS_METADATA package to retrieve and customize the DDL returned. Default settings for all indexes SQL: select DBMS_METADATA.GET_DDL('INDEX', index_name) from all_indexes where owner in (USER, 'USER_OTHER_THAN_LOGGED_IN_USER'); A pl/sql block example: set serveroutput on DECLARE V_DDL CLOB; BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false); DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', true); dbms_metadata.set_transform_param(dbms_metadata.session_transform,'TABLESPACE',false); V_DDL := DBMS_METADATA.GET_DDL('VIEW', 'A_VIEW_NAME'); DBMS_OUTPUT.PUT_LINE(V_DDL); END;
How to fetch the system generated check constraint name of table column in oracle
I have created my TEST_TABLE table using below query in oracle CREATE TABLE "PK"."TEST_TABLE" ( "MYNAME" VARCHAR2(50), "MYVAL1" NUMBER(12,0), "MYVAL2" NUMBER(12,0), "MYVAL3" NUMBER(12,0) NOT NULL, CHECK ("MYVAL1" IS NOT NULL) DEFERRABLE ENABLE NOVALIDATE ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SYSTEM" ; After this, I want to drop the check constraints applied on column MYVAL1. For this, first I need to fetch the check constraint name on column MYVAL1. The I can run the alter command to drop that constraint. So how can I fetch the exact system generated check constraint name on column MYVAL1. i tried to fetch the data using below query but as search condition is long data type column, it was trowing below error select * from user_constraints where TABLE_NAME = 'TEST_TABLE'; WHERE TABLE_NAME='TEST_TABLE' AND TO_LOB(search_condition) LIKE '%"MYVAL1" IS NOT NULL%' ERROR: ORA-00932: inconsistent datatypes: expected - got LONG 00932. 00000 - "inconsistent datatypes: expected %s got %s" *Cause: *Action: Error at Line: 23 Column: 6 Any clue?
There are two ways. First (recommended) - to give name to constraints when creating it. Second - to search in ALL_CONS_COLUMNS (or USER_CONS_COLUMNS) system view. You need something like this: select constraint_name from all_cons_columns where table_name = 'TEST_TABLE' and owner = 'PK' and column_name = 'MYVAL1' See documentation: https://docs.oracle.com/cloud/latest/db121/REFRN/refrn20045.htm#REFRN20045
How to import Oracle (C)LOB into another tablespace
I'm importing a database dump from one Oracle 10g installation into another. The source has a layout with several tablespaces. The target has one default tablespace for the user I'm importing the dump into. Everything works fine, for ordinary tables. The tables are relocated from their original tablespace to the user's default. The problem I'm facing, several tables contain CLOBs with explicit storage directives. That is, they name their storage tablespace. The imp command seems to be unable to relocate these CLOBs to the user's default tablespace. Is there any hidden command line option for the imp command to relocate the CLOB storage to the user's default tablespace or even one named tablespace? The error message ORACLE 959 looks like this: IMP-00017: Nachfolgende Anweisung war wegen Oracle-Fehler 959 erfolglos: "CREATE TABLE "IF_MDE_DATA_OUT" ("OID" NUMBER(10, 0) NOT NULL ENABLE, "CLIEN" "T_OID" NUMBER(10, 0) NOT NULL ENABLE, "TS_CREATE" TIMESTAMP (6) NOT NULL EN" "ABLE, "TS_UPDATE" TIMESTAMP (6) NOT NULL ENABLE, "OP_CREATE" VARCHAR2(30) N" "OT NULL ENABLE, "OP_UPDATE" VARCHAR2(30) NOT NULL ENABLE, "IDENTIFIER" VARC" "HAR2(50), "TRANSFERTYPE" VARCHAR2(20) NOT NULL ENABLE, "STORE" NUMBER(10, 0" "), "DATUM" DATE, "STATE" NUMBER(3, 0) NOT NULL ENABLE, "DATA_OLD" LONG RAW," " "SUPPLIER" NUMBER(10, 0), "BUYER" NUMBER(10, 0), "GOODS_OUT_IDS" VARCHAR2(" "4000), "CUSTOM_FIELD" VARCHAR2(50), "DATA_ARCHIVE" BLOB, "DATA" BLOB) PCTF" "REE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1" " FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "DATA32M" LOGGING NOCOMP" "RESS LOB ("DATA_ARCHIVE") STORE AS (TABLESPACE "DATA32M" ENABLE STORAGE IN" " ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGGING STORAGE(INITIAL 65536 FREELI" "STS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)) LOB ("DATA") STORE AS (TABLE" "SPACE "DATA32M" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGG" "ING STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAUL" "T))" IMP-00003: ORACLE-Fehler 959 aufgetreten ORA-00959: Tablespace 'DATA32M' nicht vorhanden
You could pre-create the table using the storage parameters you need, and set the import to ignore errors.
Like Karl, I recommend Datadump but use REMAP_TABLESPACE
If you are using Data Pump Dumps, you could try the remap_schema option to correct the tablespace.