Problem in truncate/drop partitions in a table having nested table columns.
Hi,
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it help?
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
Thanks in advance.
>
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table?
>
Unfortunately you can't do those operations when a table has a nested table column. No truncate, no drop, no exchange partition at the partition level.
A nested table column is stored as a separate table and acts like a 'child' table with foreign keys to the 'parent' table. It is these 'foreign keys' that prevent the truncation (just like normal foreign keys prevent truncating partions and must be disabled first) but there is no mechanism to 'disable' them.
Just one excellent example (there are many others) of why you should NOT use object columns at all.
>
IF I change column types from nested table to varray type, will it help?
>
Yes but I STRONGLY suggest you take this opportunity to change your data model to a standard relational one and put the 'child' (nested table) data into its own table with a foreign key to the parent. You can create a view on the two tables that can make data appear as if you have a nested table type if you want.
Assuming that you are going to ignore the above advice just create a new VARRAY type and a table with that type as a column. Remember VARRAYs are defined with a maximum size. So the number of nested table records needs to be within the capacity of the VARRAY type for the data to fit.
>
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
>
Sure - just CAST the nested table to the VARRAY type. Here is code for a VARRAY type and a new table that shows how to do it.
-- new array type
CREATE OR REPLACE TYPE ARRAY_T AS VARRAY(10) OF VARCHAR2(64)
-- new table using new array type - NOTE there is no nested table storage clause - arrays stored inline
CREATE TABLE partitioned_table_array
( ID_ INT,
arra_col ARRAY_T )
PARTITION BY RANGE (ID_)
( PARTITION p1 VALUES LESS THAN (40)
, PARTITION p2 VALUES LESS THAN(80)
, PARTITION p3 VALUES LESS THAN(100)
-- insert the data from the original table converting the nested table data to the varray type
INSERT INTO PARTITIONED_TABLE_ARRAY
SELECT ID_, CAST(NESTED_COL AS ARRAY_T) FROM PARTITIONED_TABLENaturally since there is no more nested table storage you can truncate or drop partitions in the above table
alter table partitioned_table_array truncate partition p1
alter table partitioned_table_array drop partition p1
Similar Messages
-
Partition exchange error on table with nested table
On Oracle 11.2.0.1, I have a partitioned table with some partitions that need to be 'archived' (in terms of moving partitions to an 'archive' table).
I have a source table like:
CREATE TABLE IS_PODACI245
ID_OBJEKTA_IDENTIFIKACIJA NUMBER(10),
ID_OBJEKTA NUMBER(20),
DATUM TIMESTAMP(6) NOT NULL,
TZ NUMBER(3),
DATA1 NUMBER(10),
DATA2 NUMBER(6),
DATA3 NUMBER(10),
DATA4 NUMBER,
DATA5 T_NTCIP_CLIMATE_TABLE
NESTED TABLE DATA5 STORE AS IS_PODACI245_STORE_TABLE
TABLESPACE DATA
PARTITION BY RANGE (DATUM)
PARTITION P_201107 VALUES LESS THAN (TIMESTAMP' 2011-08-01 00:00:00')
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE VALUES LESS THAN (MAXVALUE)
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX IDX_IS_PODACI245_KOMPLEKS ON IS_PODACI245
(ID_OBJEKTA_IDENTIFIKACIJA, ID_OBJEKTA, DATUM)
TABLESPACE DATA
LOCAL (
PARTITION P_201107
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOPARALLEL;
CREATE OR REPLACE TYPE t_ntcip_climate_table as table of t_ntcip_climate_fmt;
CREATE OR REPLACE TYPE t_ntcip_climate_FMT as object
( dev_index number(6)
, dev_description varchar2(512)
, dev_type number(10)
, dev_status number(10)
, dev_mfr_status varchar2(512)
, dev_active number(3)
, dev_test_activation number(10)
/I would like to make exchange partition using stage table, and everything is going fine on all tables, but only on a few of them (listed source is one of them, and they're only tables with nested tables wihin), where I get an error.. but sometimes ;)
on a statement like:
ALTER TABLE IS_PODACI245_ARH EXCHANGE PARTITION P_201106 WITH TABLE IS_PODACI245_STAGE EXCLUDING INDEXES WITHOUT VALIDATION;I got an error:
ORA-00001: unique constraint (TXV.SYS_C0032911) violated
it's an unique index between parent and nested table.
what could cause that problem?Dear,
I suppose that the unique constraint
ORA-00001: unique constraint (TXV.SYS_C0032911) violatedis the one you 've created on the nested table IS_PODACI245_STORE_TABLE
If so, why not disable that constraint and try again.
I have never exchanged such a kind of partitioned table having a nested table in it. But, I could imagine that the cloned non partitioned table IS_PODACI245_STAGE should at least be the exact image of the partitioned table IS_PODACI245_ARH (of course without the partition part) but with the nested table part and including all indexes
In addition, if you have a parent/child relationship between your partitioned tables, then there is a chronological order of exchange starting by the child and then finishing by the parent
see the following link for more information about this order of exchange (and comment 2 for an example also)
http://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/#more-65
Hope this helps
Mohamed Houri -
Null value in Nested table of nested table for xml guru Steve Muench
The procedure I am using takes xml document with nested levels and insert into single table using DBMS_XMLSave.insertXML.
I am able to insert into table without any error message but when I am selecting row from table, it is showing null values in all the column of nested table's inner nested table.
When I am removing nested table's nested table by replacing with object type, it is showing data of object type for the first occurance and ignoring the rest nested occurance.
Help is greatly appreciated.
Below is the sql I used to create objects and table:-
Create or Replace Type addressType as Object
Line_one varchar2(40),
Line_two varchar2(40),
City Varchar2(30),
State Varchar2(2),
zip Varchar2(10)
Create or Replace Type ce_reqType as Object
Status varchar2(25),
Status_date Date,
type_code Varchar2(25),
review_begin_date Date,
assigned_review_date date
Create or Replace type ce_reqListType
as table of ce_reqType;
Create or Replace Type LicenseType as Object
type_code Varchar2(10),
license_number Varchar2(16),
ce_requirements ce_reqListType
Create or Replace type LicenseListType
as table of LicenseType;
Create table IndividualType
individual_id Number(9),
social_security_number Varchar2(9),
Last_name varchar2(40),
First_name Varchar2(40),
Middle_name Varchar2(40),
Birth_date Date,
address addressType,
Licenses LicenseListType
nested table licenses store as licensestab
(nested table ce_requirements store as lic_ce_reqtab);Maddy wrote:
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)Because instead of adding an element to bookset collectionto are assigning (ergo replacing) it a collection containing last fetched book. Use:
declare
bookset book_table;
ln_cnt pls_integer;
begin
bookset := book_table(book_obj('madhu','kongara','sudhan'));
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
bookset := book_table(); --> Assigning back to NULL.
dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
for rec in (select * from book) loop --> Now Looping two times.
dbms_output.put_line(' name > '||rec.name);
bookset.extend;
bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract);
end loop;
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
end;
The count is 1
The count is 0
name > Harry Potter
name > Ramayana
The count is 2
PL/SQL procedure successfully completed.
SQL> Or better use bulk collect:
declare
bookset book_table;
ln_cnt pls_integer;
begin
bookset := book_table(book_obj('madhu','kongara','sudhan'));
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
bookset := book_table(); --> Assigning back to NULL.
dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
select book_obj(name,author,abstract)
bulk collect
into bookset
from book;
for i in 1..bookset.count loop --> Now Looping two times.
dbms_output.put_line(' name > '||bookset(i).name);
end loop;
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
end;
The count is 1
The count is 0
name > Harry Potter
name > Ramayana
The count is 2
PL/SQL procedure successfully completed.
SQL> SY. -
Import tables with nested table : ORA-00600
In Oracle 9.2
Create object, type as table, and table with nested table (store as syms_ntab) are successfully.
Also its export.
In process of import on another server (also 9.2, 'fromuser=one touser=two') shows errors:
. . importing table "SYMS_NTAB"
IMP-00058: ORACLE error 600 encountered
ORA-00600: internal error code, arguments: [kokeeafi1], [2], [2], [], [], [], [], []
IMP-00075: Warning: The nested table may contain partial rows or duplicate rows
But for all that table is created and error occur on phase inserting strings.
What is this?
In Oracle 8.0.5 i perform similar operation without error.From Oracle error messages and codes manual:
ORA-00600 internal error code, arguments: [string], [string], [string], [string], [string], [string], [string], [string]
Cause: This is the generic internal error number for Oracle program exceptions. It indicates that a process has encountered a low-level, unexpected condition. Causes of this message include:
* timeouts
* file corruption
* failed data checks in memory
* hardware, memory, or I/O errors
* incorrectly restored files
The first argument is the internal message number. Other arguments are various numbers, names, and character strings. The numbers may change meanings between different versions of Oracle.
Action: Report this error to Oracle Support Services after gathering the following information:
* events that led up to the error
* the operations that were attempted that led to the error
* the conditions of the operating system and databases at the time of the error
* any unusual circumstances that occurred before receiving the ORA-00600 message
* contents of any trace files generated by the error
* the relevant portions of the Alter files
Note: The cause of this message may manifest itself as different errors at different times. Be aware of the history of errors that occurred before this internal error. -
How to insert array of records in Storage table and Nested table same time??
Hi,
I am using ProC++ ( Oracle 8i) . I want to insert a host array
in a table. That table has a nested table in it. So for every
record in my host array, there are muliple records to be
inserted in Nested table. How is this possible using pro*C??
Pls help.
Thanks
NiveditaHave a look at the Oracle 9i PL/SQL manual, which has an example.
-
Error when creating table with nested table of object
Dear all,
I tried to create a table that contains nested table of an object but got an error:
create or replace type some_obj is object (
a number, b blob
4 /
Type created.
create or replace type some_type is table of some_obj;
2 /
Type created.
SQL>
create table test (obj_id number, temp some_type) nested table temp store as nes_tab;
Table created.
SQL> create table test (obj_id number, temp some_type) nested table temp store as nes_tab
ERROR at line 1:
ORA-00955: name is already used by an existing objectWhat is causing the error? How can I troubleshoot this?
best regards,
ValValerie Debonair wrote:
never mind, I put "/" at the end of the create statement that makes executing create table twice....Yep. If I'm writing a script, I tend to just stick with "/" for all my statements, including the SQL as well as the DDL, otherwise it can be confusing whether a ";" is needed or not or whether it will try and execute it twice like you found.
"/" works for all. -
Report crashes when table having lots of columns and rows, please help
Hi, Everyone,
Our system is Apex 4.0.2 with Oracle 11GR2 and Oracle HTTP server in the middle.
We have a very simple report drawing data from a table with 46 columns ( no binary data) , when the maximun rows is 500, everything is fine; but if I increase the maximum rows to 500000, it crashes repeatedly. We are doing third party database integration , our goal is using Apex simple reports with CSV exporting capability to export tables into text files which can be imported by other databases. I know there are other ways to export table into CSV file, but APEX report seems very easy to use, best of all, non programmers can use it too....
Our experience shows that: if the table has few columns, like 10 columns, we can use report to dump large number of rows like 200000, but we can't use APEX report for table with lots of columns. the HTTP server log doesn't show any meaningful information. ( we use the Apex Utilities like UNLOAD data with the same crash result).
Any suggestions are greatly appreciated."Disk cannot be read from or written to" error syncing iPod in iTunes.
-
Fixing width of a rtf table having dynamically rendered columns.
Hi All,
We have a rtf table where we are showing/hiding columns conditionally (using 'if@column').
But this is resulting in reduction of table width as well, based on number of columns getting hidden.
Is there any way, so that we can keep the overall width of table fixed, irrespective of its columns shown/hidden dynamically ?
Basically, we want to get same experience as of ADF tables, where we can set a certain column (say last column) to adjust its width (based on other no. of columns shown or hidden), so that overall table width remains fixed.
Thanks.Hi,
Thanks for the quick response.
I tried to fix the width of a column by putting 20% ,30% ....suggested by you.But it's not reflecting in the report.
is there any other way?
thanks,
chinna -
ORA-00902 on trying to Select a Nested Table
I have created a Table having Nested Table as below:
create type INT_ARRAY as table of INTEGER;
create table test1 (
id number not null,
name varchar2(500),
prot_NT int_array,
constraint test1_pk primary key(id))
STORAGE (INITIAL 512K
NEXT 512K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
nested table prot_NT store as prot_NT_TAB ;
And I am doing following select using an executeQuery on a PreparedStatement (I am not using any oracle extensions. I am using JDK1.2.2 on Solaris with Weblogic 5.1 appServer. jdbc driver is oracle.jdbc.driver.OracleDriver version 8.1.6.0.0):
Select id, name, prot_nt from test1
Some times this executeQuery works fine. But some times I get SQLException with "ORA-00902: invalid datatype". Same tables and same query behaves differently at different times.
Is there any problem with this usage?? Is there any known problem? I am trying to get Nested Table to a int[]. What is recommended procedure for doing this? Please help me out! Thanks in advance!By this point you've probably either solved the problem, or just dropped the database, but for anyone else interested, here's something you can do.
You can drop the queue table by setting event 10851 with the following steps:
1. Log into SQL*Plus or Server Manager as a user with DBA privileges.
2. Issue command: alter session set events '10851 trace name context forever, level 2'; Statement Processed.
3. Drop table <queue_table>; Statement Processed.
Solution Explanation: =====================
Event 10851 disables error 24005 when attempting to manually drop a queue table. It should be noted that this is the "Hard Way" of dropping queue tables, and should only be practiced after all formal procedures, i.e., using the "DBMS_AQADM.DROP_QUEUE_TABLE" procedure, has failed to drop the table.
Cheers,
Doug -
How to truncate a partition in owb
I wonder how can i achieve truncating a partition before loading into this target table. I found this pre-mapping prcess where we have this option of truncating a table, but how can i just truncate a partition within a table in a mapping? please advice.
~PrabhaAs per Detlef's suggestion, here's the basics that you can embedd in a function/procedure. Accepts 3 parameters in_table_name, in_subpartition_name and in_partition_name. You can also enhance ALTER statements to REUSE/DROP STORAGE if required.
v_sql VARCHAR2(250) DEFAULT NULL;
BEGIN
IF in_subpartition_name IS NOT NULL THEN
v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE SUBPARTITION '||in_subpartition_name;
ELSIF in_partition_name IS NOT NULL THEN
v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE PARTITION '||in_partition_name;
ELSE
RAISE no_data_found;
END IF;
EXECUTE IMMEDIATE v_sql; -
Problems with Whitespace using nested tables from eclipse dtp oracle plugin
Hi,
sending from eclipse to oracle xe fails if whitespace is used:
Example1: Nested table in nested table
adress_table_typ has another nested table in it
that works
CREATE TABLE x (
i INTEGER PRIMARY KEY,
adressen adress_table_typ
) NESTED TABLE adressen STORE AS adressen_nt (NESTED TABLE tels STORE AS tels_nt);
inserting a newline fails
CREATE TABLE x (
i INTEGER PRIMARY KEY,
adressen adress_table_typ
) NESTED TABLE adressen STORE AS adressen_nt
(NESTED TABLE tels STORE AS tels_nt);
Example2:
Two nested tables
CREATE TABLE x (
i INT PRIMARY KEY,
l_table_typ,
m_table_typ
) NESTED TABLE laptops STORE AS laptop_nt NESTED TABLE interessen STORE AS interessen_nt;
and then an insert
INSERT INTO x VALUES (123456,
l_typ(laptop_typ('123', 'netop'),
laptop_typ('234', 'thinkpad'),
laptop_typ('345', 'iBook')),
m_typ('a', 'b', 'c')
which fails. Note that the INSERT works when copy&pasted to sqlplus. It also works if there is
just one nested table.
Am I doing somethig wrong or is this a bug in the eclipse data tools plugin?
Regards
- Peter
PS; It is rather difficult to insert whitespace in that forum editor. Any possibility to have ascii?
For a "whitespace" question rather important...A bit of an update on the original post. I was playing around with the plug-in xml file (e.g. eclipse\plugins\org.eclipse.jst.server.generic.oc4j_1.5.100.v20070608\buildfiles\oracle.10.1.3.xml). I changed the following from "deploy" to "redeploy" and it seems to be working once the applicatoin is initial deployed. Of course, I have to change it back to "deploy" if it is the first time the application is being deployed. However; I would still would like to resolve this if there is something out there that fixes this problem. Or if everything points to an enviornment problem, I can continue to play with it.
<target name="deploy.j2ee.ear" depends="check.skip.ear.deploy" unless="skip.deploy">
<antcall target="package.module.ear"/>
<oracle:redeploy
deployerUri="${deployer.uri}"
userId="${oc4j.admin.user}"
password="${oc4j.admin.password}"
file="${server.publish.dir}/${module.name}.ear"
deploymentName="${module.name}"
bindAllWebApps="${oc4j.bind.website}"/>
</target> -
I am trying to make a nested table receive an arbitrary number of values (from a shuttle) through a loop, and then insert the table into a table of nested table in my database. The problem I am having is that when I try to insert more than one value into the nested table, it will only insert the last item in the loop into the database. Thanks in advance.
This is the code I used to create my objects:
create or replace type OUTPUT_TY as object( ATTRIBUTE_ID Number(8) )
create or replace type OUTPUTS_NT as table of OUTPUT_TY
This is my actual code in ApEx:
declare
temp_NT OUTPUTS_NT;
temp_TY OUTPUT_TY;
temp Number(10);
l_vc_arr2 htmldb_application_global.vc_arr2;
begin
temp_nt := outputs_nt();
l_vc_arr2 := HTMLDB_UTIL.string_to_table (:P2_SHUTTLE, ':');
FOR i IN 1 .. l_vc_arr2.COUNT
LOOP
temp_ty := output_ty(l_vc_arr2(i)) ;
temp_NT:= outputs_nt(temp_ty);
END LOOP;
INSERT INTO OUTPUT_TEST values (temp_NT);
commit;
end;> temp_NT:= outputs_nt (temp_ty);You are not extending the nested table / collection, you are simply assigning an entirely new collection to it for each element of l_vc_arr2.
Try something like...
FOR i IN 1 .. l_vc_arr2.COUNT LOOP
temp_ty := output_ty (l_vc_arr2 (i));
temp_nt.EXTEND;
temp_nt (temp_nt.LAST) := temp_ty;
END LOOP;Or perhaps more succintly...
FOR i IN 1 .. l_vc_arr2.COUNT LOOP
temp_nt.EXTEND;
temp_nt (temp_nt.LAST) := output_ty (l_vc_arr2 (i));
END LOOP; -
Nested Table Partitioning in 11gR2
[ Partitioning Concepts for 11gR2|http://download.oracle.com/docs/cd/E11882_01/server.112/e10837/partition.htm] says that Oracle will partition the nested table of a partitioned parent table, automatically:
"If you partition a table that has a nested table, Oracle Database uses the partitioning scheme of
the original base table as the basis for how the nested table is partitioned. This partitioning of
one base table partition for each nested table partition is called equipartitioning. By default,
nested tables are automatically partitioned when the base table is partitioned."
Here is some DDL to create a partitioned table with a nested table column:
CREATE OR REPLACE TYPE ExampElement AS OBJECT (name VARCHAR2(32), val VARCHAR2(4000))
sho err;
CREATE OR REPLACE TYPE ExampTableType AS TABLE OF ExampElement
sho err;
CREATE TABLE examp (
uida VARCHAR2(64) NOT NULL,
idx NUMBER NOT NULL,
offset SMALLINT DEFAULT -1 NOT NULL ,
elements ExampTableType,
CONSTRAINT pk_examp PRIMARY KEY (uida, idx) )
ORGANIZATION INDEX COMPRESS
PARTITION BY LIST(uida) (PARTITION IDA_0 values ('xxxxxxxxxxxxxxx') )
NESTED TABLE elements
STORE AS elements_tab((constraint pk_elts PRIMARY KEY (nested_table_id, name))
ORGANIZATION INDEX
RETURN AS LOCATOR
sho err;
I can't find any evidence that Oracle partitioned my nested table. The following do not show any entries corresponding to elements_tab or pk_elts:
SELECT table_name FROM user_part_tables ;
SELECT table_name FROM user_part_indexes ;
My question is, how can I prove to myself that the nested table has been partitioned?
Thanks,
HughThe only data dictionary entry that I can find for the elements_tab is in user_nested_tables, but it does not appear that the partitioning is visible to us.
SCOTT@orcl_11gR2> CREATE OR REPLACE TYPE ExampElement AS OBJECT (name VARCHAR2(32), val VARCHAR2(4000));
2 /
Type created.
SCOTT@orcl_11gR2> CREATE OR REPLACE TYPE ExampTableType AS TABLE OF ExampElement;
2 /
Type created.
SCOTT@orcl_11gR2> CREATE TABLE examp (
2 uida VARCHAR2(64) NOT NULL,
3 idx NUMBER NOT NULL,
4 offset SMALLINT DEFAULT -1 NOT NULL ,
5 elements ExampTableType,
6 CONSTRAINT pk_examp PRIMARY KEY (uida, idx) )
7 ORGANIZATION INDEX COMPRESS
8 PARTITION BY LIST(uida) (PARTITION IDA_0 values ('xxxxxxxxxxxxxxx') )
9 NESTED TABLE elements
10 STORE AS elements_tab((constraint pk_elts PRIMARY KEY (nested_table_id, name))
11 ORGANIZATION INDEX
12 )
13 RETURN AS LOCATOR
14 /
Table created.
SCOTT@orcl_11gR2> SELECT table_name FROM user_part_tables
2 /
TABLE_NAME
EXAMP
1 row selected.
SCOTT@orcl_11gR2> SELECT table_name FROM user_part_indexes
2 /
TABLE_NAME
EXAMP
1 row selected.
SCOTT@orcl_11gR2> SELECT table_name FROM user_tab_partitions
2 /
TABLE_NAME
EXAMP
1 row selected.
SCOTT@orcl_11gR2> SELECT table_name FROM user_nested_tables
2 /
TABLE_NAME
ELEMENTS_TAB
1 row selected.
SCOTT@orcl_11gR2> -
Error while mapping two times nested table
Hi,
I have a Product table which has nested ProductSubcategory in it.
ProductSubcategory nested table also has nested table ProductCategory inside it.
So there is a nested table inside nested table.
I designed a dimension on warehoue builder and while mapping, i got "ORA-22913: must specify table name for nested table column or attribute" error.
I mapped nested tables before with using varray iterator and expand object, but they were nested once. Is there any solution for mapping two or more time nested tables?
Now i exracted tables and i continuou working but, i wondered is there any way.
Creation codes are below. Thanx :)
CREATE TABLE PRODUCT
( PRODUCTID NUMBER NOT NULL ,
ProductSubcategory ProductSubcategory,
MODIFIEDDATE DATE NOT NULL)
NESTED TABLE ProductSubcategory STORE AS ProductSubcategory_TABLE
( NESTED TABLE ProductCategoryId STORE AS ProductCategory_TABLE);
CREATE TYPE TYPE_ProductSubcategory AS OBJECT (
ProductSubcategoryID number ,
ProductCategoryId ProductCategory ,
Name Varchar(50) ,
rowguid varchar2(100) ,
ModifiedDate date );
CREATE TYPE TYPE_ProductCategory AS OBJECT (
ProductCategoryID number ,
Name Varchar(50) ,
rowguid varchar2(100) ,
ModifiedDate date );Bharadwaj Hari wrote:
Hi,
I agree with u...I am not sure of the environment the user has so i put forth all the 3 option that crossed my mind that time....thats why i said he has to choose what best suits him/her...
Also if the database is huge and we create physical temp tables (option 2 and ur idea) its like having redundant data in the database which is also a problem....So ist upto the user to actually evaluate the situation and come up with what best suits him/her...
Regards
BharathHi,
I understand your opinion. But I am not sure that the user have enough experience to choose the best option by his one. And about the redundant data: because of this I wrote that he should truncate the tables after the last mapping which loads all data into the real target table.
Regards,
Detlef -
Data pump import error with nested tables
So the problem is somewhat long :)
Actually the problems are two - why and how oracle are treating OO concept and why data pump doesn't work?
So scenario for the 1st one:
1) there is object type h1 and table of h1
2) there is unrelated object type row_text and table of row_text
3) there is object type h2 under h1 with attribute as table of row_text
4) there is table tab1 with column b with data type as table of h1. Of course column b is stored as nested table.
So how do you think - how many nested tables Oracle will create? The correct answer is 2. One explicitly defined and one hidden with system
generated name for the type h2 which is under type h1. So the question is WHY? Why if I create an instance of supertype Oracle tries to adapt
it for the subtype as well? Even more if I create another subtype h3 under h1 another hidden nested table appears.
This was the first part.
The second part is - if I do schema export and try to import it in another schema I got error saying that oracle failed to create storage table for
nested table column b. So the second question is - if Oracle has created such a mess with hidden nested tables how to import/export to another
schema?
Ok and here is test case to demonstrate problems above:
-- creating type h1 and table of it
SQL> create or replace type h1 as object (a number)
2 not final;
3 /
Type created.
SQL> create or replace type tbl_h1 as table of h1;
2 /
Type created.
-- creating type row_text and table of it
SQL> create or replace type row_text as object (
2 txt varchar2(100))
3 not final;
4 /
Type created.
SQL> create or replace type tbl_row_text as table of row_text;
2 /
Type created.
-- creating type h2 as subtype of h1
SQL> create or replace type h2 under h1 (some_texts tbl_row_text);
2 /
Type created.
SQL> create table tab1 (a number, b tbl_h1)
2 nested table b
3 store as tab1_nested;
Table created.
-- so we have 2 nested tables now
SQL> select table_name, parent_table_name, parent_table_column
2 from user_nested_tables;
TABLE_NAME PARENT_TABLE_NAME
PARENT_TABLE_COLUMN
SYSNTfsl/+pzu3+jgQAB/AQB27g== TAB1_NESTED
TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"
TAB1_NESTED TAB1
B
-- another subtype of t1
SQL> create or replace type h3 under h1 (some_texts tbl_row_text);
2 /
Type created.
-- plus another nested table
SQL> select table_name, parent_table_name, parent_table_column
2 from user_nested_tables;
TABLE_NAME PARENT_TABLE_NAME
PARENT_TABLE_COLUMN
SYSNTfsl/+pzu3+jgQAB/AQB27g== TAB1_NESTED
TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"
SYSNTfsl/+pz03+jgQAB/AQB27g== TAB1_NESTED
TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H3")."SOME_TEXTS"
TAB1_NESTED TAB1
B
SQL> desc "SYSNTfsl/+pzu3+jgQAB/AQB27g=="
Name Null? Type
TXT VARCHAR2(100)OK let it be and now I'm trying to export and import in another schema:
[oracle@xxx]$ expdp gints/xxx@xxx directory=xxx dumpfile=gints.dmp logfile=gints.log
Export: Release 11.2.0.1.0 - Production on Thu Feb 4 22:32:48 2010
<irrelevant rows skipped>
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "GINTS"."TAB1" 0 KB 0 rows
. . exported "GINTS"."SYSNTfsl/+pz03+jgQAB/AQB27g==" 0 KB 0 rows
. . exported "GINTS"."TAB1_NESTED" 0 KB 0 rows
. . exported "GINTS"."SYSNTfsl/+pzu3+jgQAB/AQB27g==" 0 KB 0 rows
Master table "GINTS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************And now import. In order to create types transformation of OIDs is applied and also remap_schema
Although it fails to create the table.
[oracle@xxx]$ impdp gints1/xxx@xxx directory=xxx dumpfile=gints.dmp logfile=gints_imp.log remap_schema=gints:gints1 transform=OID:n
Import: Release 11.2.0.1.0 - Production on Thu Feb 4 22:41:48 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Release 11.2.0.1.0 - Production
Master table "GINTS1"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "GINTS1"."SYS_IMPORT_FULL_01": gints1/********@xxx directory=xxx dumpfile=gints.dmp logfile=gints_imp.log remap_schema=gints:gints1 transform=OID:n
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"GINTS1" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE:"GINTS1"."TAB1" failed to create with error:
ORA-02320: failure in creating storage table for nested table column B
ORA-00904: : invalid identifier
Failing sql is:
CREATE TABLE "GINTS1"."TAB1" ("A" NUMBER, "B" "GINTS1"."TBL_H1" ) 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_
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
ORA-39083: Object type INDEX_STATISTICS failed to create with error:
ORA-01403: no data found
ORA-01403: no data found
Failing sql is:
DECLARE I_N VARCHAR2(60); I_O VARCHAR2(60); c DBMS_METADATA.T_VAR_COLL; df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; BEGIN DELETE FROM "SYS"."IMPDP_STATS"; c(1) := DBMS_METADATA.GET_STAT_COLNAME('GINTS1','TAB1_NESTED',NULL,'TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"',1); DBMS_METADATA.GET_STAT_INDNAME('GINTS1','TAB1_NESTED',c,1,i_o,i_n); INSERT INTO "
ORA-39083: Object type INDEX_STATISTICS failed to create with error:
ORA-01403: no data found
ORA-01403: no data found
Failing sql is:
DECLARE I_N VARCHAR2(60); I_O VARCHAR2(60); c DBMS_METADATA.T_VAR_COLL; df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; BEGIN DELETE FROM "SYS"."IMPDP_STATS"; c(1) := DBMS_METADATA.GET_STAT_COLNAME('GINTS1','TAB1_NESTED',NULL,'TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H3")."SOME_TEXTS"',1); DBMS_METADATA.GET_STAT_INDNAME('GINTS1','TAB1_NESTED',c,1,i_o,i_n); INSERT INTO "
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "GINTS1"."SYS_IMPORT_FULL_01" completed with 4 error(s) at 22:41:52So any idea how to make export/import of such tables?
TIA
GintsTom Kyte has said it repeatedly ... I will repeat it here for you.
The fact that Oracle allows you to build object tables is not an indication that you should.
Store your data relationally and build object_views on top of them.
http://www.morganslibrary.org/reference/object_views.html
If you model properly, and store properly, you don' have any issues.
Maybe you are looking for
-
I would like to be able to hold one part of a web page static while scrolling further down, most usually when following an onscreen tutorial on fixing something with 8.1, (pretty much an everyday occurrence). This feature would be similar to that in
-
We've got several machines which use an intranet application. The app is web based and produces some PDFs on the fly which appear in popup IE windows, which in turn displays them in Adobe Reader. On 2 PCs (both running vista ie8 and ar9.2) the print
-
Moved iTunes To External Hard Drive... What's Next?
Hiya! I own a 20-inch 250GB iMac and a 320GB Western Digital External Hard Drive. I recently began running out of room on my Mac, mainly because of all that I have on iTunes. Out of my 250GB I am now down to about 18GB. With this in mind, I went out
-
Problem in x6 screen lock...
after i lock nokia x6 ... its unlocked by it self and wrong calls message have been happened with out my knowledge.. can any one help to fix this???
-
Will Dreamweaver CS4 install on a Mac with a dual processor?
I am looking to purchase Dreamweaver CS4. Adobe Customer Care seem to be confused as to whether or not it will run on an Apple Mac with a Dual 2GHz PowerPC G5 processor. At the moment they are saying it will install, but the system requirements li