Get complete ddl for index in oracle - 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;

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

Oracle update throws timeout

I am having a very simple oracle update:
update inv_li_pck_inst set mig_li_pck_inst_id = 9377 where id = 9384
Both records exist in the table inv_li_pck_inst: id=9377 and id=9384
Record with id=9377 is migration record.
Problem is that this very simple update query takes ages to run - and at the end throws timeout exception. What could possibly be wrong here? IDs in the table inv_li_pck_inst are unique.
Table DDL:
CREATE TABLE "TESTING_INV"."INV_LI_PCK_INST"
( "ID" NUMBER NOT NULL ENABLE,
"LI_PCK_ID" NUMBER NOT NULL ENABLE,
"WORKFLOW_ID" NUMBER,
"INSERTED" DATE NOT NULL ENABLE,
"INSERTED_BY" NUMBER(9,0) NOT NULL ENABLE,
"UPDATED" DATE,
"UPDATED_BY" NUMBER(9,0),
"DELETED" DATE,
"DELETED_BY" NUMBER(9,0),
"MIG_LI_PCK_INST_ID" NUMBER,
"STATUS_ID" NUMBER,
"WFI_ID" NUMBER,
"TOF_WFI_ID" NUMBER,
CONSTRAINT "PK_INV_LI_PCK_INST" 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 "TESTING_INV_DATA" ENABLE,
CONSTRAINT "FK_LPI_WORKFLOW" FOREIGN KEY ("WORKFLOW_ID")
REFERENCES "TESTING_INV"."WORKFLOW" ("WORKFLOW_ID") ENABLE,
CONSTRAINT "FK_LIPI_STATUS" FOREIGN KEY ("STATUS_ID")
REFERENCES "TESTING_INV"."INV_LI_PCK_INST_STATUS" ("ID") ENABLE,
CONSTRAINT "FK_LIPI_MIG_PCK_INST" FOREIGN KEY ("MIG_LI_PCK_INST_ID")
REFERENCES "TESTING_INV"."INV_LI_PCK_INST" ("ID") ENABLE,
CONSTRAINT "FK_LI_PCK_INST_WFI" FOREIGN KEY ("WFI_ID")
REFERENCES "TESTING_INV"."WFI" ("WFI_ID") ENABLE,
CONSTRAINT "FK_INV_LI_PCK_INST5" FOREIGN KEY ("TOF_WFI_ID")
REFERENCES "TESTING_INV"."WFI" ("WFI_ID") ENABLE,
CONSTRAINT "FK_LPI_LI_PCK" FOREIGN KEY ("LI_PCK_ID")
REFERENCES "TESTING_INV"."INV_LI_PCK" ("ID") ENABLE
) 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 "TESTING_INV_DATA" ;
CREATE INDEX "TESTING_INV"."IDX_LI_PCK_INST_WFI" ON "TESTING_INV"."INV_LI_PCK_INST" ("WFI_ID")
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 "TESTING_INV_DATA" ;
CREATE UNIQUE INDEX "TESTING_INV"."UN_LI_PCK_INST" ON "TESTING_INV"."INV_LI_PCK_INST" (NVL2("DELETED","ID",NULL), "WORKFLOW_ID")
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 "TESTING_INV_DATA" ;
CREATE OR REPLACE EDITIONABLE TRIGGER "TESTING_INV"."TRG_INV_LI_PCK_INST"
before insert on INV_LI_PCK_INST
for each row
begin
select SEQ_INV_LI_PCK_INST.nextval into :new.ID from dual;
end;
/
ALTER TRIGGER "TESTING_INV"."TRG_INV_LI_PCK_INST" ENABLE;
Most probable scenario is that there is an other migration session (or more of them) and it blocks your session.
Simple setup
create table testing
(ID NUMBER primary key,
MIG_ID NUMBER );
alter table testing add (
constraint mig foreign key(MIG_ID) references testing(id));
insert into testing (id, mig_id) values(9384, null);
insert into testing (id, mig_id) values(9377, null);
commit;
If you now performs the UPDATE is goes perfectly smooth:
update testing set mig_id = 9377 where id = 9384;
But if you before the update performs a delete of the migrated ID form an other session and do not commit it, your update will "hang" forever.
-- perform from other session and do not commit
delete from testing where id = 9377;
Why, because if the update would be done and the delete session would be commited - the referential integrity will be violeted. The UPDATE must wait until the deleted is commited or rollbacked to see if the reference ID is there or not.
How to dignose?
Simple check the v$session (or GV of RAC) and see the blocking_status and event
select SID, SERIAL#,STATUS,SQL_ID, BLOCKING_SESSION_STATUS, BLOCKING_SESSION,EVENT
from v$session
where USERNAME = your_user
You will see (most probably) your session with BLOCKING_SESSION_STATUS = VALID and
EVENT = enq: TX - row lock contention. In BLOCKING_SESSION you can find the session ID of your interacting session.
The SQL_ID will tell you what the other session is doing.

DECLARE A FOREIGN KEY CONSTRAINT causes ORA-00907

I have a create table statement, but it's not compile,
The fk_myFirstTable CONSTRAINT cause the problem.
Someone know what wrong in the CONSTRAINT ?
I get : ORA-00907: - "missing right parenthesis"
CREATE TABLE "mySchema"."mySecondTable "
(
idNumber NUMBER(10,0) NOT NULL ENABLE,
SystemId NUMBER(10,0) NOT NULL ENABLE,
CONSTRAINT "mySecondTable _PK" PRIMARY KEY (idNumber ),
CONSTRAINT "fk_myFirstTable" FOREIGN KEY (SystemId) REFERENCES myFirstTable(SystemId)
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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "MYTBS" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 0 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 "MYTBS" ;
thanks for help!
The USING INDEX clause is part of the primary key constraint. I moved the foreign key constraint to after the ENABLE,.
Try this:
CREATE TABLE "mySchema"."mySecondTable "
(
idNumber NUMBER(10,0) NOT NULL ENABLE,
SystemId NUMBER(10,0) NOT NULL ENABLE,
CONSTRAINT "mySecondTable _PK" PRIMARY KEY (idNumber )
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 FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "MYTBS" ENABLE,
CONSTRAINT "fk_myFirstTable" FOREIGN KEY (SystemId) REFERENCES myFirstTable(SystemId)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 0 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 "MYTBS" ;
I have a stupid space in the declare line:
CREATE TABLE "mySchema"."mySecondTable "
instead of:
CREATE TABLE "mySchema"."mySecondTable"
Sorry for the lack of attention!
A few objections, if I may: you didn't write that code, did you? It suspiciously looks like a copy/paste from some GUI which - true - fetches all that information from dictionary and creates a jungle, when all you need is a bush.
Don't enclose Oracle objects' names into double quotes and - even worse - use mixed case within those double quotes. Otherwise, you'll have to reference them using double quotes, the same mixed case, ALWAYS. A true nightmare. By default, Oracle will create them using uppercase, but you can reference them using any case (lower, mixed, upper - just don't store them as such!).
NO: "mySecondTable " - note a trailing space - horror!
YES (as their name will be stored in UPPERCASE anyway):
mysecondtable
MYSECONDTABLE
mySecondTable
There's no need to specify NOT NULL for column(s) that make(s) primary key constraint; by default, they can't be NULL.
All that storage mumbo-jumbo ... phew, if this is an ordinary table we use for daily purposes, you really shouldn't take care about it and let Oracle handle those information. I agree - no problem in specifying all that if you know what they are. Reading your question, I think you should rely on Oracle.
Shortened, your query might/should look as follows (I'm creating the my_first_table, just to make the foreign key constraint work):
SQL> create table my_first_table
2 (system_id number constraint pk_mft primary key);
Table created.
SQL> create table my_second_table
2 (id_number number constraint pk_mst primary key,
3 system_id number constraint fk_my_first_table references my_first_table (system_id)
4 not null
5 );
Table created.
SQL>

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 get an Oracle sql text from a dmp file?

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;
/

Resources