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,
Hugh

The 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>

Similar Messages

  • Partitioned nested table error while dropping one partition

    All,
    I created a partitioned table which is also a nested table as you can see below. I got FK constraint error while attempting to drop a partition, however, I could not find the FK in order to disable it since it's underlying table emp_list_p which is not visiable to applications. How could I drop the partition in this case?
    Thanks,
    Jianhui
    SQL>desc emp_t
    Name Null? Type
    ENO NUMBER
    ENAME VARCHAR2(30)
    SAL NUMBER
    SQL>desc emp_list_t
    emp_list_t TABLE OF EMP_T
    Name Null? Type
    ENO NUMBER
    ENAME VARCHAR2(30)
    SAL NUMBER
    SQL>l
    1 create table dept_p
    2 (dno number,
    3 dname varchar2(30),
    4 emplist emp_list_t )
    5 NESTED TABLE emplist store as emp_list_p
    6 partition by range (dno)
    7 (
    8 partition p1 values less than (2),
    9 partition p2 values less than (3)
    10* )
    SQL>/
    Table created.
    SQL>insert into dept_p (select * from dept);
    2 rows created.
    SQL>select * from dept_p;
    DNO DNAME
    EMPLIST(ENO, ENAME, SAL)
    1 HR
    EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
    2 SALES
    EMP_LIST_T(EMP_T(3, 'frank', 800))
    2 rows selected.
    SQL>alter table dept_p drop partition p1;
    alter table dept_p drop partition p1
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL>l
    1 select constraint_name, constraint_type, table_name
    2 from user_constraints
    3 where r_constraint_name=(select constraint_name
    4* from user_constraints where table_name='DEPT_P' and constraint_type in ('P','U'))
    SQL>/
    no rows selected

    SQL> create type emp_t as object(
      2  ENO NUMBER,
      3  ENAME VARCHAR2(30),
      4  SAL NUMBER)
      5  /
    Type created.
    SQL> create type emp_list_t as table of emp_t;
      2  /
    Type created.
    SQL> desc emp_list_t
    emp_list_t TABLE OF EMP_T
    Name                                      Null?    Type
    ENO                                                NUMBER
    ENAME                                              VARCHAR2(30)
    SAL                                                NUMBER
    SQL> create table dept_p
      2  (dno number,
      3  dname varchar2(30),
      4  emplist emp_list_t )
      5  NESTED TABLE emplist store as emp_list_p
      6  partition by range (dno)
      7   (
      8   partition p1 values less than (2),
      9   partition p2 values less than (3)
    10   )
    11  /
    Table created.
    SQL> insert into dept_p values(1, 'HR',
      2  EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000)));
    1 row created.
    SQL>
    SQL> insert into dept_p values(2, 'SALES',EMP_LIST_T(EMP_T(3, 'frank', 800)));
    1 row created.
    SQL> select * from dept_p;
           DNO DNAME
    EMPLIST(ENO, ENAME, SAL)
             1 HR
    EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
             2 SALES
    EMP_LIST_T(EMP_T(3, 'frank', 800))
    SQL> alter table dept_p drop partition p1;
    alter table dept_p drop partition p1
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select constraint_name,table_name,constraint_type from user_constraints
      2  where table_name = 'DEPT_P';
    CONSTRAINT_NAME                TABLE_NAME                     C
    SYS_C008224                    DEPT_P                         U
    SQL> select index_name from user_constraints
      2  where table_name = 'DEPT_P';
    INDEX_NAME
    SYS_C008224
    SQL> select index_name,column_name from user_ind_columns
      2  where index_name = 'SYS_C008224';
    INDEX_NAME                     COLUMN_NAME
    SYS_C008224                    EMPLIST
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
    With the Partitioning, OLAP and Data Mining options
    If you look closely, there is a unique index on dept_p.  Oracle does not advertise it.
    One of the options is that you may have to delete the rows in the partition first,
    then drop the partition.

  • 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

  • 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

  • Best way of partitioning the huge size table in oracle 11gr2

    hi,
    OS: linux
    DB: oracle 11gR2
    table size is about 2T and single table space with multiple dbf files in ASM,
    table partition with dbms.redefinition is running past 2 days (range partition).. its running but not that fast..
    note: exchange partition is too slow.. hence not used..
    what is the best way of doing the huge size table partition. please suggest, thanks.

    >
    what is the best way of doing the huge size table partition
    >
    A few questions
    1. Is that an OLTP or OLAP table?
    2. Is all of the data still needed online or is some of it archivable?
    3. What type of partitiioning are you doing? RANGE? LIST? COMPOSITE?
    4. Why do you you say 'exchange partition is too slow' - did you do a test?
    For example if data will be partitioned by create date then one stragety is to initially put all existing data into the root partition of a range partitioned table. Then you can start using new partitions for new incoming data and take your time to partition the current data.

  • Nested tables and multiset operators in Oracle 10g

    Consider the following scenario:
    We have two identical relations R and S defined as:
    CREATE TABLE R(
    a INTEGER,
    b table_type)
    NESTED TABLE b STORE as b_1;
    CREATE TABLE S(
    a INTEGER,
    b table_type)
    NESTED TABLE b STORE as b_2;
    where table_typ is defined as
    CREATE TYPE table_typ AS TABLE OF VARCHAR2(8);
    Suppose we have two instances of R and S, each having one tuple as follows: R(1,table_typ('a','b')) and S(1,table_typ('b','c')).
    I would like to "merge" these two simple instances (e.g., achieve the effect of a simple SELECT * FROM R UNION SELECT * FROM S query) and obtain the following resulting instance: Result(1,table_typ('a','b','c')).
    Would this be possible in Oracle 10g? A simple UNION does not work (I got a "inconsistent datatypes: expected - got SCOTT.TABLE_TYP" error). I also took a look at the MULTISET UNION operator over nested tables available in Oracle 10g, but it doesn't seem to get me anywhere. Any help on this would be greatly appreciated.
    Thank you,
    Laura

    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
      2  /
    Type created.
    SQL> CREATE TABLE r(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_1;
    Table created.
    SQL> CREATE TABLE s(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_2;
    Table created.
    SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
    1 row created.
    SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
    1 row created.
    SQL> COLUMN c FORMAT A10;
    SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
      2  FROM   r, s
      3  WHERE  r.a = s.a;
             A C
             1 TABLE_TYPE('a', 'b', 'c')
    SQL>

  • 10g Nested Tables and APEX

    Trying to use the following within Apex:
    CREATE TYPE location_typ AS OBJECT (
    location_id NUMBER(4),
    street_address VARCHAR2(40),
    postal_code VARCHAR2(12),
    city VARCHAR2(30),
    state_province VARCHAR2(25));
    CREATE TYPE nt_location_typ AS TABLE OF location_typ;
    CREATE TYPE country_typ AS OBJECT (
    country_id CHAR(2),
    country_name VARCHAR2(40),
    locations nt_location_typ);
    CREATE TYPE nt_country_typ AS TABLE OF country_typ;
    CREATE TABLE region_tab (
    region_id NUMBER,
    region_name VARCHAR2(25),
    countries nt_country_typ)
    NESTED TABLE countries STORE AS nt_countries_tab (
    (PRIMARY KEY (NESTED_TABLE_ID, country_id))
    ORGANIZATION INDEX COMPRESS
    NESTED TABLE locations STORE AS nt_locations_tab);
    Can get Apex to function in the Tabular Report mode by modifying the query to use the correct syntax:
    select "REGION_ID",
    "REGION_NAME",
    c.COUNTRY_ID,
    c.COUNTRY_NAME,
    l.LOCATION_ID,
    l.STREET_ADDRESS, l.POSTAL_CODE,
    l.CITY,
    l.STATE_PROVINCE
    from "#OWNER#"."REGION_TAB", TABLE(COUNTRIES) C, TABLE(LOCATIONS) L
    Built a 'Maintenance' form. Put the Region base column on it. Then built a tabular form (with an updateable query) on the same page to access the first level Nest ( countries). Haven't figured out how to actually edit the values yet, but feel comfortable I will.
    But - trying to provide editing to the 2nd level nested table elements creates a problem. First, only 1 updateable query can be on a page. Hmmm - so to get around this I guess I have to build a new page that the calling updateable query will access when selecting one of the tabular form elements. Not elegant by any means. Was hoping to provide a blank form on the right side that would be populated by the Location Nested Table values when a select was made on the first level nest. Oh well.
    Just curious how anyone has handled this? I could pass stack between pages for sure, but was hoping page regions would be sufficient to handle this.
    Any white papers on this? Anything in the DEMO area to use as a template? The default Demo doesn't provide this based on querying user objects.
    Thanks,
    Dwight Taylor

    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
      2  /
    Type created.
    SQL> CREATE TABLE r(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_1;
    Table created.
    SQL> CREATE TABLE s(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_2;
    Table created.
    SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
    1 row created.
    SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
    1 row created.
    SQL> COLUMN c FORMAT A10;
    SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
      2  FROM   r, s
      3  WHERE  r.a = s.a;
             A C
             1 TABLE_TYPE('a', 'b', 'c')
    SQL>

  • Using SQL with Nested Table

    Hi ,
    Please assist as how can we do this thing
    i have a nested table of object type
    create or replace type a1 as object
    a number,
    b varchar2(30),
    region varchar2(30)
    create type a1_array s table of a1;
    declare
    v_a1 a1;
    v_a1_array a1_array:=a1_array();
      begin
    v_a1= a1(1, '1' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(1):=v_a1;
    v_a1= a1(2, '2' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(2):=v_a1;
    v_a1= a1(3, '3' , 'NAM');
    v_a1_array.EXTEND;
    v_a1_array(3):=v_a1;
      end;
    Now, i have v_a1_array having 3 rows 2 with AUS region and one with NAM region.
    Using SQL can i extract only 'AUS'  rows and fetch in  ARRAY OF TYPE v_a1_array (using Where clause  and Table () functions )
    Any help will be highly appreciated. Please assist. I have oracle 11g
    Thanks

    Hi,
    GPU has already shown you how to do. I will just modify my original one:
    SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 22 22:14:42 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2     v_a1           a1;
      3     v_a1_array     a1_array := a1_array ();
      4     v_a1_array2    a1_array;
      5  BEGIN
      6     v_a1 := a1 (1, '1', 'AUS');
      7     v_a1_array.EXTEND;
      8     v_a1_array (1) := v_a1;
      9     v_a1 := a1 (2, '2', 'AUS');
    10     v_a1_array.EXTEND;
    11     v_a1_array (2) := v_a1;
    12     v_a1 := a1 (3, '3', 'NAM');
    13     v_a1_array.EXTEND;
    14     v_a1_array (3) := v_a1;
    15
    16     SELECT a1(a, b, region)
    17       BULK COLLECT INTO v_a1_array2
    18       FROM TABLE (v_a1_array)
    19      WHERE region = 'AUS';
    20
    21     FOR c1 IN (SELECT *
    22                  FROM TABLE (v_a1_array2))
    23     LOOP
    24        DBMS_OUTPUT.put_line ('A='||c1.a||', B='||c1.b||', REGION='||c1.region);
    25     END LOOP;
    26  END;
    27  /
    A=1, B=1, REGION=AUS
    A=2, B=2, REGION=AUS
    PL/SQL procedure successfully completed.
    If you consider your question answered, please mark this thread as answered.
    Regards.
    Alberto

  • Nested Tables - Oracle Crashes !

    Hello Everyone
    You might help me to sleep tonight.
    Ok, here is the problem.
    I used a nested table to collect data. After collection, I get repeated records in collection result. I tried to operate to get a distinct result operating SQL operation but oracle gives nasty error and kicks me out the session.
    HERE is the code :
    create or replace package rule_engine
    as
    type t_course_count is table of number(2);
    Procedure main;
    end rule_engine;
    create or replace package body rule_engine
    as
    procedure main
    is
    v_course_count t_course_count:=t_course_count(1,2,3,4);
    i t_course_count;
    begin
    insert into table(i) select * from table(v_course_count);
    end main;
    end rule_engine;
    null

    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
      2  /
    Type created.
    SQL> CREATE TABLE r(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_1;
    Table created.
    SQL> CREATE TABLE s(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_2;
    Table created.
    SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
    1 row created.
    SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
    1 row created.
    SQL> COLUMN c FORMAT A10;
    SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
      2  FROM   r, s
      3  WHERE  r.a = s.a;
             A C
             1 TABLE_TYPE('a', 'b', 'c')
    SQL>

  • ***Unable to import table which consists of nested tables

    Dear all;
    I have a problem on migrating my Oracle 8.1.7 database from windows nt environment into the ibm aix 4.3.3 environment. I have been using the import export utility. Exporting the data from the database does not produce any error but importing the export file produces the error as below;
    Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.0.0 - Production
    Export file created by EXPORT:V08.01.07 via conventional path
    import done in WE8ISO8859P1 character set and WE8ISO8859P1 NCHAR character set
    . importing IIMS's objects into IIMS
    IMP-00017: following statement failed with ORACLE error 2331:
    "CREATE TABLE "CMGC_CURRENCY" ("CODE" VARCHAR2(10) NOT NULL ENABLE, "DESCP" "
    "VARCHAR2(60) NOT NULL ENABLE, "X_RATE" NUMBER(10, 6) NOT NULL ENABLE, "X_DA"
    "TE" VARCHAR2(10), "REMARK" VARCHAR2(255), "YEAR" NUMBER(4, 0) NOT NULL ENAB"
    "LE, "BANK_AC" VARCHAR2(20) NOT NULL ENABLE, "NSTBL_LEDG" "NSTBL_LEDGLIST" N"
    "OT NULL ENABLE, "NSTBL_XRATE" "NSTBL_XRATELIST" NOT NULL ENABLE) PCTFREE 1"
    "0 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING STORAGE(INITIAL 65536) TABLESP"
    "ACE "IIMS" NESTED TABLE "NSTBL_LEDG" STORE AS "NSTBL_LEDGLIST_LIST" RETURN "
    "AS VALUE NESTED TABLE "NSTBL_XRATE" STORE AS "NSTBL_XRATELIST_LIST" RETURN"
    " AS VALUE "
    IMP-00003: ORACLE error 2331 encountered
    ORA-02331: cannot create constraint on column of datatype Named Table Type
    Import terminated successfully with warnings.
    It seems that the error only occur when importing tables which consists on nested tables. I have done exporting and importing from windows NT into windows NT and from windows NT into AIX but the problem still arises. Please help.
    NSTBL_LEDG and NSTBL_XRATE are the nested tables with NSTBL_LEDGLIST and NSTBL_XRATELIST as the datatype accordingly.
    Thanks in advance;
    andrew

    Hi Sayak,
    This means we need to installed Oracle client to resolve this problem. Can you please share if you have some knowledge regarding the same.
    Thanks,
    Mohit

  • Nested tables as separate lines in output

    I'm working with Adobe forms using transaction SFP from the ABAP Workbench. I'm trying to construct a prototype of an SD invoice, with one internal table having the basic item data, and then a secondary table with further information, such as discounts, taxes, etc. The item number is part of both tables so that they can be related to each other. Using right-click and Create in the context I constructed a loop on the main table, and then under that a loop on the secondary table, with the equal item number as a condition. It all works, but in the output the secondary data comes out on the same line as the main item data, and when I try to drag it down to the next line in the layout, it changes its position in the data view also, so that it's outside the loop and prints only once, over the second main item line. Surely for an invoice or a purchase order it's normal to have one basic item line, and then one or more other lines with various other information for each item. It's very easy in both SAPscript and Smart Forms to have a loop within a loop displaying separate lines, but so far I haven't been able to get it to work with Adobe.

    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
      2  /
    Type created.
    SQL> CREATE TABLE r(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_1;
    Table created.
    SQL> CREATE TABLE s(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_2;
    Table created.
    SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
    1 row created.
    SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
    1 row created.
    SQL> COLUMN c FORMAT A10;
    SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
      2  FROM   r, s
      3  WHERE  r.a = s.a;
             A C
             1 TABLE_TYPE('a', 'b', 'c')
    SQL>

  • ROWNUM equivalent for Nested Tables?

    Is there an equivalent to the ROWNUM pseudocolumn for a nested table such that something like this...
    WITH driver_data AS
      (SELECT 1 AS id, sys.dbms_debug_vc2coll('a','b','c') AS val FROM dual
      UNION ALL
      SELECT 2 AS id, sys.dbms_debug_vc2coll('x','y','z') AS val FROM dual)
    SELECT t1.id,
      --t2.rownum as pos,
      t2.column_value AS val
    FROM driver_data t1,
         TABLE(t1.val) t2 ;
    ID     VAL
    1     a
    1     b
    1     c
    2     x
    2     y
    2     z...would return something like this...
    ID     VAL  POS
    1     a      1
    1     b      2
    1     c      3
    2     x      1
    2     y      2
    2     z      3

    ABB wrote:
    But the OP now has two collections per row of data, not one, as he showed above, so it becomes more complicated.Yes, it does. But still solvable:
    with t1 as (
                select  t1.*,
                        rownum rn_main
                  from  driver_data t1
         t2 as (
                select  id,
                        val1,
                        rn_main,
                        row_number() over(partition by rn_main order by rn_nested) pos
                  from  (
                         select  id,
                                 column_value val1,
                                 rn_main,
                                 rownum rn_nested
                           from  t1,
                           table(val1)
         t3 as (
                select  id,
                        val2,
                        rn_main,
                        row_number() over(partition by rn_main order by rn_nested) pos
                  from  (
                         select  id,
                                 column_value val2,
                                 rn_main,
                                 rownum rn_nested
                           from  t1,
                           table(val2)
    select  nvl(t2.id,t3.id) id,
            val1,
            val2,
            nvl(t2.pos,t3.pos) pos
      from  t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
      order by nvl(t2.rn_main,t3.rn_main),
               nvl(t2.pos,t3.pos)
    SQL> create table driver_data(
      2                           id number,
      3                           val1 sys.dbms_debug_vc2coll,
      4                           val2 sys.dbms_debug_vc2coll
      5                          )
      6    nested table val1 store as val1_tbl,
      7    nested table val2 store as val2_tbl
      8  /
    Table created.
    SQL> insert
      2    into driver_data
      3    SELECT  1 id,
      4            sys.dbms_debug_vc2coll('c','b','a') val1,
      5            sys.dbms_debug_vc2coll('k','u') val2
      6      FROM  dual
      7   UNION ALL
      8    SELECT  2 id,
      9            sys.dbms_debug_vc2coll('z','y','x') val1,
    10            sys.dbms_debug_vc2coll('n','e','j','t') val2
    11      FROM  dual
    12   UNION ALL
    13    SELECT  1 id,
    14            sys.dbms_debug_vc2coll('c','b','a') val1,
    15            sys.dbms_debug_vc2coll('k','u') val2
    16      FROM  dual
    17   UNION ALL
    18    SELECT  2 id,
    19            sys.dbms_debug_vc2coll('z','y','x') val1,
    20            sys.dbms_debug_vc2coll('n','e','j','t') val2
    21      FROM  dual
    22  /
    4 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> column val1 format a10
    SQL> column val2 format a10
    SQL> with t1 as (
      2              select  t1.*,
      3                      rownum rn_main
      4                from  driver_data t1
      5             ),
      6       t2 as (
      7              select  id,
      8                      val1,
      9                      rn_main,
    10                      row_number() over(partition by rn_main order by rn_nested) pos
    11                from  (
    12                       select  id,
    13                               column_value val1,
    14                               rn_main,
    15                               rownum rn_nested
    16                         from  t1,
    17                         table(val1)
    18                      )
    19             ),
    20       t3 as (
    21              select  id,
    22                      val2,
    23                      rn_main,
    24                      row_number() over(partition by rn_main order by rn_nested) pos
    25                from  (
    26                       select  id,
    27                               column_value val2,
    28                               rn_main,
    29                               rownum rn_nested
    30                         from  t1,
    31                         table(val2)
    32                      )
    33             )
    34  select  nvl(t2.id,t3.id) id,
    35          val1,
    36          val2,
    37          nvl(t2.pos,t3.pos) pos
    38    from  t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
    39    order by nvl(t2.rn_main,t3.rn_main),
    40             nvl(t2.pos,t3.pos)
    41  /
            ID VAL1       VAL2              POS
             1 c          k                   1
             1 b          u                   2
             1 a                              3
             2 z          n                   1
             2 y          e                   2
             2 x          j                   3
             2            t                   4
             1 c          k                   1
             1 b          u                   2
             1 a                              3
             2 z          n                   1
            ID VAL1       VAL2              POS
             2 y          e                   2
             2 x          j                   3
             2            t                   4
    14 rows selected.
    SQL> SY.

  • Adding nested table to object table

    if I alter an object type and add a nested table to it, there seem to be no syntax to add "STORE AS" clause for that nested table in the object table containing the altered object type. E.G.:
    ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
    where Own_Name_ntt is a nested table type, then
    ALTER TABLE FD_DOT NESTED TABLE Own_Name STORE AS Own_Name_ntab;
    does not work but the table FD_DOT can not be used since it lacks the storage for the newly added nested table.

    Check your syntax.
    CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
    CREATE TYPE fd_dao AS OBJECT
    (col1        date
    ,col2        number);
    CREATE TABLE fd_dot(cola varchar2(10)
                       ,colb date);
    ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
    ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
        NESTED TABLE Own_Name STORE AS Own_Name_ntab;
    SQL> CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
      2  /
    Type created.
    SQL>
    SQL> CREATE TYPE fd_dao AS OBJECT
      2   (col1        date
      3   ,col2        number);
      4  /
    Type created.
    SQL>
    SQL> CREATE TABLE fd_dot(cola varchar2(10)
      2                     ,colb date);
    Table created.
    SQL>
    SQL> ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
    Type altered.
    SQL>
    SQL> ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
      2      NESTED TABLE Own_Name STORE AS Own_Name_ntab;
    Table altered.
    SQL> desc fd_dot
    Name                                                                          Null?    Type
    COLA                                                                                   VARCHAR2(10)
    COLB                                                                                   DATE
    OWN_NAME                                                                               OWN_NAME_NTT
    SQL> desc fd_dao
    Name                                                                          Null?    Type
    COL1                                                                                   DATE
    COL2                                                                                   NUMBER
    OWN_NAME                                                                               OWN_NAME_NTT
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining options
    SQL> CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
      2  /
    Type created.
    SQL>
    SQL> CREATE TYPE fd_dao AS OBJECT
      2   (col1        date
      3   ,col2        number);
      4  /
    Type created.
    SQL>
    SQL> CREATE TABLE fd_dot(cola varchar2(10)
      2                     ,colb date);
    Table created.
    SQL>
    SQL> ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
    Type altered.
    SQL>
    SQL> ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
      2      NESTED TABLE Own_Name STORE AS Own_Name_ntab;
    Table altered.
    SQL> desc fd_dao
    Name                                                                          Null?    Type
    COL1                                                                                   DATE
    COL2                                                                                   NUMBER
    OWN_NAME                                                                               OWN_NAME_NTT
    SQL> desc fd_dot
    Name                                                                          Null?    Type
    COLA                                                                                   VARCHAR2(10)
    COLB                                                                                   DATE
    OWN_NAME                                                                               OWN_NAME_NTT
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.3.0 - Production

  • Oracle Tables Partitioning

    I am planning for table partitioning of existing tables...
    database is production 10gR1 i need it to upgrade to 11gR2 and also implement table partitioning. what should be the best way to do so with minimum downtime and zero data loss. Please advice. size of the tables are 20 to 40GB.. source database is in solaris and planning to migrate on linux.

    my question is for partitioning with minimum downtime with zero data loss.
    the scenario is like
    I took a export of source table and create a new partitioned table with different name, then import the data into new table, drop the source table and rename the new partitioned table with the source tables's name. Its all fine because there will be very minimum downtime but here we will loss some data. It is because the transactions which are done in the mean time will not be in the exported file. Is there any way another..? I hope you got my question.

  • Create index partition in the table partition tablespace

    Hello,
    I am running a custom job that
    * Creates a tablespace daily
    * Creates the daily table partition in the tablespace created
    * Drops the tablepartition X days old
    * Drops the tablespace for that partition on X+1 day.
    The above job runs perfectly, but 'm having issues with managing the indexes for these partitioned tables. In the old database (10g - Single Node), all the partitions/indexes existed in one BIG tablespace and when I imported the table creation script into the new database, I modified all the table partitions & indexes to go into their respective tablespace.
    Eg:
    Table_name........Partition_name.....................Index_Part_name..........................Tablespace_name
    ============...================............====================...........=================
    TABL1...................TABL1_2012_07_16............TABL1_IDX_2012_07_16............TBS_2012_07_16
    TABL1...................TABL1_2012_07_15............TABL1_IDX_2012_07_15............TBS_2012_07_15
    But now when the job runs, it creates the index into the default tablespace TBS_DATA.
    Table_name........Partition_name.....................Index_Part_name..........................Tablespace_name
    ============...================.............====================...........=================
    TABL1...................TABL1_2012_08_16............TABL1_IDX_2012_08_16............TBS_DATA
    TABL1...................TABL1_2012_08_15............TABL1_IDX_2012_08_15............TBS_DATA
    I can issue alter index rebuild to move the indexes to its default tablespace, but how can I ensure that the index gets created in its designated tablespace?
    NOTE - the partition/tablespace management job that I run only creates the table partition and not the index.
    The new env is a 2-Node 11gR2 RAC cluster on Linux x86_64.
    Thanks in advance,
    aBBy.

    Excerpt from the job -
    This creates the partition into the new tablespace.
    v_sql_new_part := 'alter table '||tab_owner||'.'||tab_name||' add partition '||v_new_part_nm||'
    values less than (to_date('''||v_new_part_dt_formatted||''',''DD-MON-YYYY'')) tablespace '||part_tbs;
    execute immediate v_sql_new_part;New tablespace for new partition - because this is a 10T database and having multiple tablespaces helps with backup/recovery.
    Thanks,
    aBBy.

Maybe you are looking for

  • Driver cart graphic for HP Pavilion 15 win 8.1 - 64bits

    Hi plz  i need this driver for HP Pavilion 15 win 8.1 - 64bits 

  • Withholding Tax not picking for the current Fiscal year 2014

    Dear Gurus, Withholding tax assigned to the vendor is getting picked up for the fiscal year 2013 but when the same vendor is invoiced for year 2014 with the same WHT tax code we could see that there is no tax line getting generated against the Vendor

  • Export a query results to CSV

    Hi all, I am currently planning to develop a program that does the following things: 1. Connects to the Oracle database 2. Runs a query 3. Export the results of the query to a CSV file in a folder If theres anyone out there who has experienced in sim

  • Powerpoint Sildes to Go. Notes cannot be edited

    Tried to use this app for a business meeting and noticed a few glaring ommissions 1) When views the notes you only see 3 lines 2) You cannot edit the notes 3) when I Tilt the PB I expect the format to change so I can see more notes.

  • Conditions in BPM

    Hi Experts, Scenario : SOAP -> First webservice -> Second Webservice -> Third Webservice Requirement : If the EmpId from the SOAP client request is 234 then I have to call the first webservice otherwise I have to skip the First webservice from the bu