PRIMARY KEY PARTITIONED INDEXES 생성방법 (ORA-2429, ORA-1408)

제품 : ORACLE SERVER
작성날짜 : 2004-08-13
PRIMARY KEY PARTITIONED INDEXES 생성방법 (ORA-2429, ORA-1408)
============================================================
PURPOSE
primary key partitioned indexes 를 생성하는 방법을 알아 봅니다.
SCOPE
Oracle Partitioning Option은 8~10g Standard Edition에서는 지원하지
않는다.
Example:
SQL> -- 먼저 partitioned table TEST_A 를 생성합니다.
SQL>
SQL> CREATE TABLE test_a (col1 number, col2 number, col3 varchar2(20))
2 PARTITION BY RANGE (col1, col2)
3 (partition part_test_a_1 values less than (10, 100),
4 partition part_test_a_2 values less than (20, 200),
5 partition part_test_a_3 values less than (30, 300),
6 partition part_test_a_4 values less than (40, 400));
Table created.
SQL> -- partitioned table TEST_B 를 생성합니다.
SQL>
SQL> CREATE TABLE test_b (col1 number, col2 number, col3 varchar2(20))
2 PARTITION BY RANGE (col1, col2)
3 (partition part_test_b_1 values less than (10, 100),
4 partition part_test_b_2 values less than (20, 200),
5 partition part_test_b_3 values less than (30, 300),
6 partition part_test_b_4 values less than (40, 400));
Table created.
SQL> -- TEST_A 테이블에
SQL> -- non-unique local partitioned index, IX_TEST_A 를 생성합니다.
SQL>
SQL> CREATE INDEX ix_test_a ON test_a(col1, col2)
2 LOCAL
3 (partition ix_test_a_1,
4 partition ix_test_a_2,
5 partition ix_test_a_3,
6 partition ix_test_a_4);
Index created.
SQL> -- TEST_B 테이블에
SQL> -- unique global partitioned index, IX_TEST_B 를 생성합니다.
SQL>
SQL> CREATE UNIQUE INDEX ix_test_b1 ON test_b(col1, col2)
2 GLOBAL PARTITION BY RANGE (col1, col2)
3 (partition ix_test_b1_1 values less than (20, 200),
4 partition ix_test_b1_2 values less than (maxvalue, maxvalue));
Index created.
SQL> -- TEST_A 테이블에 rimary key constraint (PK_TEST_A) 를 추가 합니다.
SQL>
SQL> ALTER TABLE test_a ADD CONSTRAINT pk_test_a
2 PRIMARY KEY (col2, col1);
Table altered.
SQL> -- index IX_TEST_A 를 drop 하려고 하면 다음 에러가 발생합니다.
SQL>
SQL> DROP INDEX ix_test_a;
drop index ix_test_a
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key
SQL> -- TEST_B 테이블에 partition IX_TEST_B1 에서 사용된 같은 columns 들을 사용해서
SQL> -- 새로운 두번째 index (IX_TEST_B2) 를 생성하려고 하면
SQL> -- 다음 에러가 발생합니다.
SQL>
SQL> CREATE INDEX ix_test_b2 ON test_b(col1, col2)
2 LOCAL;
create index ix_test_b2 on test_b(col1, col2)
ERROR at line 1:
ORA-01408: such column list already indexed
SQL> -- TEST_B 테이블에 primary key constraint (PK_TEST_B) 를 추가 합니다.
SQL>
SQL> ALTER TABLE test_b ADD CONSTRAINT pk_test_b
2 PRIMARY KEY (col1, col2);
Table altered.
SQL> -- index IX_TEST_B1 를 drop 하려고 하면 다음 에러가 발생합니다.
SQL>
SQL> DROP INDEX ix_test_b1;
drop index ix_test_b1
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key
SQL> -- indexes 들과 각 indexes 이 걸려있는 tables 의 목록입니다.
SQL>
SQL> SELECT index_name, partition_name, status
2 FROM user_ind_partitions
3 ORDER BY index_name, partition_name;
INDEX_NAME PARTITION_NAME STATUS
IX_TEST_A IX_TEST_A_1 USABLE
IX_TEST_A IX_TEST_A_2 USABLE
IX_TEST_A IX_TEST_A_3 USABLE
IX_TEST_A IX_TEST_A_4 USABLE
IX_TEST_B1 IX_TEST_B1_1 USABLE
IX_TEST_B1 IX_TEST_B1_2 USABLE
6 rows selected.
SQL> -- TEST_A 테이블에서 primary key constraint 를 drop 합니다.
SQL>
SQL> ALTER TABLE test_a DROP CONSTRAINT pk_test_a;
Table altered.
SQL> -- TEST_B 테이블에서 primary key constraint 를 drop 합니다.
SQL>
SQL> ALTER TABLE test_b DROP CONSTRAINT pk_test_b;
Table altered.
SQL> -- indexes 들과 각 indexes 이 걸려있는 tables 의 목록을 다시 봅니다.
SQL> -- 여기서 주의해서 보아야 할 것은 non-unique local partitioned index (IX_TEST_A)
SQL> -- 은 drop 되지 않고 USABLE 상태로 남아 있다는 것입니다.
SQL> -- 이렇게 되는 이유는 index (IX_TEST_A) 가 non-unique 이기 때문입니다.
SQL> -- 반면 unique global partitioned index (IX_TEST_B) 은 drop 되었습니다.
SQL>
SQL> SELECT index_name, partition_name, status
2 FROM user_ind_partitions
3 ORDER BY index_name, partition_name;
INDEX_NAME PARTITION_NAME STATUS
IX_TEST_A IX_TEST_A_1 USABLE
IX_TEST_A IX_TEST_A_2 USABLE
IX_TEST_A IX_TEST_A_3 USABLE
IX_TEST_A IX_TEST_A_4 USABLE
만일 index 가 primary key 에 정의되어 있는 columns 들과 같은 columns
을 사용해서 만들어 졌다면 primary key 는 그 underlying index 를 사용합니다.
이것은 index 가 unique 이건 non-unique 이건 또는 global 이건 local partioned index
이건 관계없이 적용됩니다.
위의 예제에서 primary key 가 non-unique index 위에 생성되었다는 것을
주의해 보시기 바랍니다. 이렇게 되는 이유는 index 안의 값들이 사실
모두 unique 하기 때문입니다. 그렇지 않을 경우 다음 에러가 발생하게 됩니다.
"ORA-02437: cannot enable (STEELY.PK_TEST_B) - primary key violated."
2개의 indexes 가 같은 순서의 같은 columns 을 사용해서 만들어 질 수는 없습니다.
위의 예제에서 TEST_B 테이블에 두번째 index (IX_TEST_B2) 를 만들려고
했을때 다음에러가 발생하는것을 확인할 수 있었습니다.
"ORA-01408: such column list already indexed."
하지만 columns 들의 순서를 바꾼다면 같은 columns 들을 사용하더라도
추가적으로 indexes 를 생성할 수 있습니다.
index (IX_TEST_A) 와 primary key (PK_TEST_A) 에 정의된 column 순서는
반대로 되어 있습니다. 그러나 primary key 는 IX_TEST_A 를 underlying index
로 사용하고 있습니다.
테이블에서 primary key constraint 가 drop 되었을때
만일 index 가 UNIQUE index 로 생성되었다면 대응하는 index 또한 drop 됩니다.
이 현상은 LOCAL 또는 GLOBAL partitioned indexes 모두에 적용됩니다.
partitioning 을 최대한 활용하기 위해서는 partitioned tables/indexes
를 생성할 때에 STORAGE clause 를 반드시 사용해야 합니다.
Reference Documents
<Note:74224.1>

First, thanks for posting the code that lets us reproduce your test. That is essential for issues like this.
Because the primary key is global you will not be able to use
INCLUDING INDEXES
WITH VALIDATION;And you will need to add the primary key to the temp table
ALTER TABLE DEMO_INTERVAL_DATA_LOAD_Y ADD CONSTRAINT IDX_DEMO_ROLL_Y PRIMARY KEY (ROLL_NUM);The the exchange will work. You will need to rebuild the primary key after the exchange.

Similar Messages

  • Assigning primary key and index for a table

    I have a database consisting of only one table with 10 million rows which mostly looks like this:
    RECORDDATE                     ID     CLASS     VALUE
    24-JAN-12 10.52.47.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     6     38
    24-JAN-12 10.53.05.000000 AM     253     16     197
    24-JAN-12 10.53.06.000000 AM     98     10     150
    24-JAN-12 10.53.06.000000 AM     98     0     0
    24-JAN-12 10.53.06.000000 AM     98     4     0
    24-JAN-12 10.53.06.000000 AM     98     11     33As you can see there are several entries that look exactly the same. Currently, I don't have primary key or index for any column and have a lot of performance issues. For example this query takes more than 10 seconds to run:
    select distinct      ID
    from      scdatabase4
    where ID < 253
    order by 1Since database is not my primary job and have no background of it, I'm really confused about what to do to fix my issues. Could someone please help me in assigning primary key and index if you agree that this is the problem?!

    Execute the query below to help decide what column to index:
    SELECT COLUMN_NAME, NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY
    FROM DBA_TAB_COL_STATISTICS
    WHERE TABLE_NAME = 'your_table_name'
    ORDER BY COLUMN_NAME;
    The important columns are:
    1) NUM_DISTINCTS: Indicates the number of distinct values. If this number is very low for a column, it indicates that this column is not a very good candidate for a B-Tree index.
    2) NUM_NULL: Indicates the number of null values for each column. A column with few null values is a good candidate for a index
    But be aware, this is not a rule, it's just a method to help decide which column will have the most benefit of index creation.

  • Primary keys and index

    Hi,
       I got these question in interview Plz answer them
       1. Maximum number of primary keys u can use for a table?
       2. Maximum number of indexes u can create?
       3. Maximum number of secondary indexes?
       4. Maximum number fields in a table?
       5. Maximum length of primary key field?
    Plz answer these questions
    regards,
    kumar

    >>1. Maximum number of primary keys u can use for a table?
    16
    >>2. Maximum number of indexes u can create?
    >>3. Maximum number of secondary indexes?
    Only 16 Primary Index and n number of secondary indexes.
    >>4. Maximum number fields in a table?
    249
    >>5. Maximum length of primary key field?
    255
    Cheers,
    Hakim
    Mark all useful answers..Close the thread once your question has been answered.

  • Creating a script for a PRIMARY KEY USING INDEX SORT doesn't work

    Probably a bug.
    h1. Environment
    Application: Oracle SQL Developer Data Modeler
    Version: 3.0.0.655
    h1. Test Case:
    1. Create a new table TRANSACTIONS with some columns.
    2. Mark one of numeric columns as the primary key - PK_TRANSACTIONS.
    3. Go to Physical Models and create new Oracle Database 11g.
    4. Go to Physical Models -> Oracle Database 11g -> Tables -> TRANSACTIONS -> Primary Keys -> PK_TRANSACTIONS -> Properties:
    a) on General tab set Using Index to BY INDEX NAME
    b) on Using Index tab choose a tablespace
    c) on Using Index tab set Index Sort to SORTED.
    5. Export the schema to DDL script. For the primary key you will get something like this:
    ALTER TABLE TRANSACTION
    ADD CONSTRAINT PK_TRANSACTION PRIMARY KEY ( TRAN_ID ) DEFERRABLE
    USING INDEX
    PCTFREE 10
    MAXTRANS 255
    TABLESPACE TBSPC_INDX
    LOGGING
    STORAGE (
    INITIAL 65536
    NEXT 1048576
    PCTINCREASE 0
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    FREELISTS 1
    FREELIST GROUPS 1
    BUFFER_POOL DEFAULT
    ) SORTED
    h1. Reason of failure
    The script will fail because SORTED is not allowed here. It should be SORT.
    Additionally, the default behaviour for Data Modeler is to set Index Sort to NO but default setting for Oracle database 11g is SORT. Shouldn't Data Modeler use SORT as the default value?
    Edited by: user7420841 on 2011-05-07 03:15

    Hi,
    Thanks for reporting this problem. As you say, it should be SORT rather than SORTED. I have logged a bug on this.
    I also agree that, for consistency with the database default, it would be better to have SORT as the default in Data Modeler.
    David

  • Primary key on view - ORA-20505

    I'm getting this error when I try to update a form that is based on a view:
    ORA-20505: Error in DML: p_rowid=69, p_alt_rowid=VENDOR_ITEM_ID, p_rowid2=, p_alt_rowid2=. ORA-01779: cannot modify a column which maps to a non key-preserved table
    Error Unable to process row of table SH_PURCHASING_VW.
    OK
    Can you tell me how to add a pk to this view? I'd like to use VENDOR_ITEM_ID or a completely new column.
    CREATE OR REPLACE FORCE VIEW "SH_PURCHASING_VW" ("ITEMNO", "VENDNO", "ITEM_DESC", "VEND_NAME", "PRIORITY", "VEND_ITEMNO", "VEND_ITEM_NOTES", "VENDOR_ITEM_ID", "VENDOR_ID", "VEND_NOTES", "ITEM_NOTES_ID", "ITEMNO_N", "ITEM_NOTES") AS
    select     "SH_VENDOR_ITEM"."ITEMNO" as "ITEMNO",
         "SH_VENDOR_ITEM"."VENDNO" as "VENDNO",
         "SH_VENDOR_ITEM"."ITEM_DESC" as "ITEM_DESC",
         "SH_VENDOR_ITEM"."VEND_NAME" as "VEND_NAME",
         "SH_VENDOR_ITEM"."PRIORITY" as "PRIORITY",
         "SH_VENDOR_ITEM"."VEND_ITEMNO" as "VEND_ITEMNO",
         "SH_VENDOR_ITEM"."VEND_ITEM_NOTES" as "VEND_ITEM_NOTES",
         "SH_VENDOR_ITEM"."VENDOR_ITEM_ID" as "VENDOR_ITEM_ID",
         "SH_VENDOR"."VENDOR_ID" as "VENDOR_ID",
         "SH_VENDOR"."VEND_NOTES" as "VEND_NOTES",
         "SH_ITEM_NOTES"."ITEM_NOTES_ID" as "ITEM_NOTES_ID",
         "SH_ITEM_NOTES"."ITEMNO_N" as "ITEMNO_N",
         "SH_ITEM_NOTES"."ITEM_NOTES" as "ITEM_NOTES"
    from     "SH_ITEM_NOTES" "SH_ITEM_NOTES",
         "SH_VENDOR" "SH_VENDOR",
         "SH_VENDOR_ITEM" "SH_VENDOR_ITEM"
    where "SH_VENDOR_ITEM"."VENDNO"="SH_VENDOR"."VENDNO"
    and     "SH_VENDOR_ITEM"."ITEMNO"="SH_ITEM_NOTES"."ITEMNO_N"
    ORDER BY VENDOR_ITEM_ID
    Thanks in advance!

    Here are the updateable columns
    SPICE_HUNTER1 SH_PURCHASING_VW ITEMNO NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VENDNO NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW ITEM_DESC NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VEND_NAME NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW PRIORITY NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VEND_ITEMNO NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VEND_ITEM_NOTES NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VENDOR_ITEM_ID NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VENDOR_ID NO NO NO
    SPICE_HUNTER1 SH_PURCHASING_VW VEND_NOTES NO NO NO
    VENDOR_ID and ITEM_ID are the pks for those tables. I'm guessing I need to add a VENDOR_ID and an ITEM_ID to the VENDOR_ITEM table, then write a couple of update statements to get those fields popluated with their respective data. I'm reading up on 'key-preserved' tables and it's making sense. You will probably laugh, but I AM the "DBA." I'm actually the report developer for our company and we're trying out APEX to see if we can use it to redo a bunch of old poorly-designed Access databases. I'm flying by the skin of my teeth, the seat of my pants, and a bunch of deep sighs. I went through the basic APEx training about a year ago, am designing tables as I go only through my knowledge of query/report writing and keep coming up against things in APEX that keep me saying, "Huhhhhhhh?"
    Our purchasing department has an old poorly designed Access DB from which they can search vendors or items then see the results on one page. They need to be able to view the three areas of notes based on each search, i.e. they search by item then get this:
    Item # and Description
    Item Specific Notes Text Area
    Vendor # and Name
    Vendor Item Notes Text Area
    Vendor Specific Notes Text Area
    They search by Vendor they get this:
    Vendor # and Name
    Vendor Specific Notes Text Area
    Item # and Description
    Vendor Item NOtes Text Area
    Item Speicfic Notes Text Area
    Then, they need to be able to update those fields with any new information and that needs to update to their respective tables. I'm sure it's easy, and I'm sure it has to do with my LIMITED prowess of setting up my tables and learning that I can't have one form update more than one table (I learned that somewhere on this journey, hence the tries with the view) so I keep getting these ideas of how to do it, then running into snags.
    So thanks for your help!
    Alexandra

  • Update on primary key in indexed table

    I need to update an ID# in a table that has been indexed on ID# (and two other columns) using the indextype is ctxsys.context method. Oracle 10g is throwing the following errors:
    ORA-20000 "failed in the execution of the ODCINDEXUPDATE routine"
    DRG-50857 "oracle error in textindexmethods.ODCIndexUpdate
    ORA-20000 "Oracle Text error:
    DRG-10602 "failed to queue DML change to column ID# for pimary key AAAMlpAABAAAPy3AAA"
    DRG-50857 "oracle error in drekqkd(execute k-stmt)
    ORA-00942 "table or view does not exist"
    ORA-06512 at "CTXSYS.DRUE", line 160
    ORA-06512 at "CTXSYS.TEXTINDEXMETHODS", line 678
    Any help would be appreciated as to what I can do to accomplish the update.
    Larry

    hi,
    can you plz post your update statement...
    thanks,
    baskar.l

  • Problems creating a partitioned primary key index.

    I am creating a partitioned table and I noticed that when I use the constraint option of the create table the primary key is not partitioned. I then tried using the using index clause and specifying the create index local and that is giving errors. Here is my current syntax that is causing the errors:
    create table redef_temp (
         USER_ID          VARCHAR2(32),
         GROUP_ID     VARCHAR2(32),
         JOIN_DATE     DATE DEFAULT SYSDATE NOT NULL,
         constraint primary key
         using index (create index pk_redef_temp
    on redef_temp (USER_ID, GROUP_ID)
    LOCAL STORE IN (IDX)))
    tablespace data
    partition by hash (user_id)
         (PARTITION ic_x_user_group_part_p1 tablespace DATA,
         PARTITION ic_x_user_group_part_p2 tablespace DATA,
         PARTITION ic_x_user_group_part_p3 tablespace DATA,
         PARTITION ic_x_user_group_part_p4 tablespace DATA)
    PARALLEL ENABLE ROW MOVEMENT;
    Thanks

    The following works on 9.2.0.8 and 10.2.0.3:
    create table redef_temp (
         USER_ID VARCHAR2(32),
         GROUP_ID VARCHAR2(32),
         JOIN_DATE DATE DEFAULT SYSDATE NOT NULL,
         constraint pk_redef_temp primary key (user_id, group_id)
         using index (
              create index pk_redef_temp
              on redef_temp (USER_ID, GROUP_ID)
              LOCAL tablespace test_8k
    tablespace test_8k
    partition by hash (user_id) (
         PARTITION ic_x_user_group_part_p1 tablespace test_8k,
         PARTITION ic_x_user_group_part_p2 tablespace test_8k,
         PARTITION ic_x_user_group_part_p3 tablespace test_8k,
         PARTITION ic_x_user_group_part_p4 tablespace test_8k
    PARALLEL ENABLE ROW MOVEMENT
    /Your syntax for the constraint definition was wrong, and your use of 'store in' for the index tablespace was wrong. I've had to change all tablespace names to 'test_8k'.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • How to Create primary key index with duplicate rows.

    Hi All,
    While rebuilding an index on a table , I am getting error that there are duplicate rows in a table.
    Searching out the reason led me to an interesting observation.
    Please follow.
    SELECT * FROM user_ind_columns WHERE table_name='SERVICE_STATUS';
    INDEX_NAME     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION     COLUMN_LENGTH     CHAR_LENGTH     DESCEND
    SERVICE_STATUS_PK     SERVICE_STATUS     SUBSCR_NO_RESETS     2     22     0      ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     STATUS_TYPE_ID     3     22     0     ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     ACTIVE_DT     4     7     0     ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     SUBSCR_NO     1     22     0     ASC
    SELECT index_name,index_type,table_name,table_type,uniqueness, status,partitioned FROM user_indexes WHERE index_name='SERVICE_STATUS_PK';
    INDEX_NAME     INDEX_TYPE      TABLE_NAME     TABLE_TYPE     UNIQUENESS     STATUS     PARTITIONED
    SERVICE_STATUS_PK     NORMAL     SERVICE_STATUS     TABLE     UNIQUE     VALID     NO
    SELECT constraint_name ,constraint_type,table_name,status,DEFERRABLE,DEFERRED,validated,index_name
    FROM user_constraints WHERE constraint_name='SERVICE_STATUS_PK';
    CONSTRAINT_NAME     CONSTRAINT_TYPE     TABLE_NAME      STATUS     DEFERRABLE     DEFERRED     VALIDATED     INDEX_NAME
    SERVICE_STATUS_PK     P     SERVICE_STATUS     ENABLED     NOT DEFERRABLE     IMMEDIATE VALIDATED     SERVICE_STATUS_PK
    1. Using index scan:
    SELECT COUNT (*)
    FROM (SELECT subscr_no, active_dt, status_type_id, subscr_no_resets
    FROM service_status
    GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
    HAVING COUNT (*) > 1) ;
    no rows returned
    Explain plan:
    Operation     OBJECT Name     ROWS     Bytes     Cost     OBJECT Node     IN/OUT     PStart     PStop
    SELECT STATEMENT Optimizer MODE=CHOOSE          519 K          14756                     
    FILTER                                        
    SORT GROUP BY NOSORT          519 K     7 M     14756                     
    INDEX FULL SCAN     ARBOR.SERVICE_STATUS_PK     10 M     158 M     49184                     
    2. Using Full scan:
    SELECT COUNT (*)
    FROM (SELECT /*+ full(s) */ subscr_no, active_dt, status_type_id, subscr_no_resets
    FROM service_status s
    GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
    HAVING COUNT (*) > 1) ;
    71054 rows returned.
    Explain Plan:
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          1           24123                     
    SORT AGGREGATE          1                               
    VIEW          519 K          24123                     
    FILTER                                        
    SORT GROUP BY          519 K     7 M     24123                     
    TABLE ACCESS FULL     ARBOR.SERVICE_STATUS     10 M     158 M     4234                     
    Index SERVICE_STATUS_PK is a unique and composite primary key VALID index. And the constraint is ENABLED and VALIDATED still having duplicate rows in table.
    How it is possible?
    Is it an Oracle soft Bug??
    Regards,
    Saket Bansal

    saket bansal wrote:
    Values are inserted as single rows inserts through an GUI interface.And you still claim to have over 71K duplicate records, without the GUI getting any kind of errors?
    That does not add up and can only be explained by a "bug".
    I tried inserting a duplicate record but failed.
    SQL> insert into service_status (select * from service_status where rownum <2);
    insert into service_status (select * from service_status where rownum <2)
    ERROR at line 1:
    ORA-00001: unique constraint (ARBOR.SERVICE_STATUS_PK) violatedAre you really sure there is no other way data in this table is populated/manipulated in bulk?

  • Index of a primary key constraint

    Hi,
    I have to remove (temporarily) a primary key constraint (of a table) to can convert its columns to unicode ones.
    Found that after delete the PK (with "ALTER TABLE %s DROP CONSTRAINT %s" SQL command) sometimes remain its unique index, sometimes not.
    I guess the system does not remove it, if it was created by user command (and not with PK by system).
    Am I right?
    Can I get this information of the property of index of PK? (to be able to decide to need delete it as a second step)
    Please do not offer to check its existance after deletion of PK :-)
    I had used to get index properties with "user_indexes" view.
    Regards,
    Imre

    Found that after delete the PK (with "ALTER TABLE %s DROP CONSTRAINT %s" SQL command) sometimes remain its unique index, sometimes not.You may force to always delete the index by
    alter table my_table drop primary key drop index;or alternatively
    alter table my_table drop primary key keep index;

  • Help with primary key problem

    Oracle 9.2.0 on Red Hat Linux advanced server 2.1
    (There are a number of large tables that this applies to)
    I have a partitioned table where during the creation of the table a Primary key was declared and was placed 'using index tablespace primary_key'. So the table is created, and the primary key is set to use the 'primary_key' tablespace.
    Since our loads are quite large, we disable constraints during the load process, then enable them after the load has completed. Here's the problem, when the constraints are enabled, the tablespace for constraints change to the default tablespace of the schema owner.
    We have a specific tablespace created to hold the primary keys of the various tables, called 'primary_key'. The schema owner has his own default tablespace called 'POWER1'. When the schema owner runs the enable script to enable the primary keys, they all start being placed in 'POWER1' which is not nearly as large as 'primary_key' and as a result the first couple primary keys are created in 'POWER1' and then 'unable to extend segment in tablespace POWER1' pops up and the rest of the primary keys fail to enable.
    The workaround for this is to set the default tablespace for the schema owner to to be 'primary_key' but that is not what we really want.
    any feedback on this is appreciated, thanks

    In the old days, when we disabled a primary constraint, Oracle dropped the index. When we re-enabled the constraint the index was built again. But, if we didn't specify the index tablspace when we re-enabled the constraint the index was built in the default tablespace. Which is what is happening to you now.
    In 9i Oracle added the KEEP INDEX clause, which allowed us to retain the index even though the primary key was no longer enforced. However, as your aim is to increase the speed of data take on, you in fact want the index dropped. So, what you need to do is:
    ALTER TABLE whatever DISABLE PRIMARY KEY
    DROP INDEX;
    ALTER TABLE whatever ENABLE PRIMARY KEY
    USING INDEX TABLESPACE indx;Cheers, APC

  • Help with primary key

    Ok,
    I have gotten the value of the PK. When I try to pass the parameter to a Rowset Navigator as _ROWKEY, the rowkeys have shifted. I am using the same View Object however. How do I keep the View Object instanciated in order to pass the RSN the correct PK?
    thanks

    In the old days, when we disabled a primary constraint, Oracle dropped the index. When we re-enabled the constraint the index was built again. But, if we didn't specify the index tablspace when we re-enabled the constraint the index was built in the default tablespace. Which is what is happening to you now.
    In 9i Oracle added the KEEP INDEX clause, which allowed us to retain the index even though the primary key was no longer enforced. However, as your aim is to increase the speed of data take on, you in fact want the index dropped. So, what you need to do is:
    ALTER TABLE whatever DISABLE PRIMARY KEY
    DROP INDEX;
    ALTER TABLE whatever ENABLE PRIMARY KEY
    USING INDEX TABLESPACE indx;Cheers, APC

  • ORA-02266: unique/primary keys - error while using Exchange Partition

    Hi All,
    While using EXCHANGE PARTITION statement as given below,
    ALTER TABLE SOURCE_TABLE EXCHANGE PARTITION PRT_EXCG_PRTN WITH TABLE TARGET_TABLE
    we are getting this error,
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    However, there are no tables have foreign keys referring this TARGET_TABLE, we checked this by referring
    USER_CONSTRAINTS table, it has only primary key and NOT NULL constraints.
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME like 'TARGET_TABLE';
    We are using the following version,
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE     9.2.0.6.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    Is it due to any error in our end or it could be a bug in Oracle and should we go for any patch updation ?
    Please guide us to resolve this error as soon as possible, thank you.
    Regards,
    Deva

    *** Duplicate Post ***
    Please Ignore.

  • Creating Primary key Index as Local Partitioned Index.

    CREATE TABLE T1(
    x NUMBER,
    y NUMBER
    )PARTITION BY LIST(x)
    PARTITION P1 VALUES (1),
    PARTITION P2 VALUES (2),
    PARTITION Pmax VALUES (default)
    ALTER TABLE T1 ADD CONSTRAINT T1_PK PRIMARY KEY(Y) LOCAL;
    Error starting at line 1 in command:
    ALTER TABLE T1 ADD CONSTRAINT T1_PK PRIMARY KEY(Y) LOCAL
    Error report:
    SQL Error: ORA-01735: invalid ALTER TABLE option
    01735. 00000 - "invalid ALTER TABLE option"
    *Cause:   
    *Action:
    Can you please help me how to achieve this in Oracle 10g R2?

    LOCAL keyword is invalid with ALTER TABLEDepends:
    SQL>  create table t1 (x number, y number)
    partition by list (x)
       (partition p1
           values (1),
        partition p2
           values (2),
        partition pmax
           values (default))
    Table created.
    SQL>  alter table t1 add constraint t1_pk primary key(x, y) using index local
    Table altered.

  • ORA-02266: unique/primary keys in table referenced by enabled foreign keys

    Hi,
    I am trying to delete data from a table by dropping a partition. I have identified all the child tables by running the following command.
    select 'select count(*) from '||table_name||' where employee_id = 100;'
    from dba_constraints
    where constraint_type='R'
    and r_constraint_name in
    (select constraint_name from dba_constraints
    where constraint_type in ('P','U') and table_name='EMPLOYEE);
    'SELECTCOUNT(*)FROM'||TABLE_NAME||'WHEREEMPLOYEE_ID_ID=100;'
    select count(*) from PT_ORDERS where employee_id = 100;
    select count(*) from PT_DEP where employee_id = 100;
    select count(*) from PT_SKILLSET where employee_id = 100;
    I dropped the partition for employee_id 100 in all of the child tables. The select count(*) returns 0 rows for each of the above.
    When I try to run the below command on the EMPLOYEE table, I get 'ORA-02266: unique/primary keys in table referenced by enabled foreign keys'.
    alter table EMPLOYEE drop partition EMP_ID_100;
    I cant see why I am unable to drop this partition now as there is now child data in any of the referenced tables. Any suggestions or help on this would be greatly appreciated.
    Thanks.
    Rgs,
    Rob

    You should disable foreign key constraints first and drop partition. Deletion of rows or dropping partitions in childs don't work in this case
    as you have the global dependency:
    <PRE>
    SQL> create table scott.t (x int primary key, y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> create table scott.t_c (x int references scott.t(x), y int)
    2 partition by list (y) (
    3 partition p_1 values(1), partition p_2 values(2))
    4 /
    Table created.
    SQL> insert into scott.t values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t values(2,2)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(1,1)
    2 /
    1 row created.
    SQL> insert into scott.t_c values(2,2)
    2 /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter table scott.t_c drop partition p_2;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    alter table scott.t drop partition p_2
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'P'
    3 and table_name = 'T';
    CONSTRAINT_NAME
    SYS_C0011058
    SQL> select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'R'
    3 and r_constraint_name = 'SYS_C0011058';
    CONSTRAINT_NAME
    SYS_C0011059
    SQL> alter table scott.t_c disable constraint SYS_C0011059;
    Table altered.
    SQL> alter table scott.t drop partition p_2;
    Table altered.
    SQL> alter table scott.t_c enable novalidate constraint SYS_C0011059;
    Table altered.
    </PRE>
    I guess you should consider such option as Referencial partitioning (with some restrictions).
    Best wishes,
    Dmitry.

  • ORA-00604 ORA-00904 When query partitioned table with partitioned indexes

    Got ORA-00604 ORA-00904 When query partitioned table with partitioned indexes in the data warehouse environment.
    Query runs fine when query the partitioned table without partitioned indexes.
    Here is the query.
    SELECT al2.vdc_name, al7.model_series_name, COUNT (DISTINCT (al1.vin)),
    al27.accessory_code
    FROM vlc.veh_vdc_accessorization_fact al1,
    vlc.vdc_dim al2,
    vlc.model_attribute_dim al7,
    vlc.ppo_list_dim al18,
    vlc.ppo_list_indiv_type_dim al23,
    vlc.accy_type_dim al27
    WHERE ( al2.vdc_id = al1.vdc_location_id
    AND al7.model_attribute_id = al1.model_attribute_id
    AND al18.mydppolist_id = al1.ppo_list_id
    AND al23.mydppolist_id = al18.mydppolist_id
    AND al23.mydaccytyp_id = al27.mydaccytyp_id
    AND ( al7.model_series_name IN ('SCION TC', 'SCION XA', 'SCION XB')
    AND al2.vdc_name IN
    ('PORT OF BALTIMORE',
    'PORT OF JACKSONVILLE - LEXUS',
    'PORT OF LONG BEACH',
    'PORT OF NEWARK',
    'PORT OF PORTLAND'
    AND al27.accessory_code IN ('42', '43', '44', '45')
    GROUP BY al2.vdc_name, al7.model_series_name, al27.accessory_code

    I would recommend that you post this at the following OTN forum:
    Database - General
    General Database Discussions
    and perhaps at:
    Oracle Warehouse Builder
    Warehouse Builder
    The Oracle OLAP forum typically does not cover general data warehousing topics.

Maybe you are looking for

  • Address Book Label Layout

    I'm using mail to print address labels. Several addressees are couples with different last names. If I list one of the couple as a spouse or partner in my address book, the program will list both names on the first line of the label. However, it's in

  • Odd graphic in mail headers

    My sister is seeing an odd image when examining the headers of a received email. When her mouse rolls over an area (I guess where address book info links are) then this huge circle appears. Its a powder blue circle with a small, white, downward point

  • MDS on Tomcat server

    Hi, JDeveloper 11g, Tomcat server. I am planning to deploy the ADF Application on Tomcat server. My question is, Is it possible to configure the MDS on Tomcat server? Please let me know. Thanks.

  • How to check CRL validity Period before doing CA Migration ?

    Hi ALL, I am performing a CA migration so for doing that my first step is to Check that CRLs have a validity period that extends past expected migration duration So can any one please let me know how can I check the CRLS validity period ?? If not, pu

  • IDoc adapter inbound channel: Error Fehler beim Le

    Hello, I have a BIG problem. I want to use IDOC - XI - IDOC. I have configured the connections. But when I send the Idoc to the XI. it returns a code in the SM58 "IDoc adapter inbound channel: Error Fehler beim Le" The Message comes cut, it doesn't r