by specifying the index tablespace in to disable the primary key constraint

Hello
during the ETL I want to disable constraints PK/UK to speed up the load;
on activation of the constraint, the corresponding indices are created in a different tablespace while they were initially on the creation of the table itself
I tried to disable PK / UK with the option 'keep the index', the index value corresponding to the status of "unusable" and use ' alter session set skip_unusable_indexes = true', but then I can't insert rows with the error.
Error: ORA-01502: index 'xxx' or partition of such index is in unusable state
can anyone tell if there is a way to allow the PK/UK constraint and specify the storage space for the corresponding indices, or keep the index and inserts works?
I'd like to avoid to drop constraints / indexes and re-create them both from scratch after the load
Thank you for the advice
Thank you
Rgds

>
can anyone tell if there is a way to allow the PK/UK constraint and specify the storage space for the corresponding indices, or keep the index and inserts works?
I'd like to avoid to drop constraints / indexes and re-create them both from scratch after the load
>
Have you tried specifying the table space in the USING clause when you activate the constraint?

ALTER TABLE emp ENABLE PRIMARY KEY USING INDEX TABLESPACE myTS;

See DBA guide
http://docs.Oracle.com/CD/B28359_01/server.111/b28310/indexes003.htm
>
Creating an Index associated with a constraint

Oracle database applies a UNIQUE key or a constraint integrity PRIMARY KEY on a table by creating a unique index on the unique key or primary key. This index is created automatically by the database when the constraint is enabled. No action is required by you when you run the CREATE TABLE or ALTER TABLE statement to create the index, but you can optionally specify an ESCALATION using clause to exercise control over his creation. This includes them when a constraint is defined and enabled, and when a constraint defined but disabled is selected.
>
Note the last sentence two sentences:
>
You can optionally specify an ESCALATION using clause to exercise control over his creation. This includes them when a constraint is defined and enabled, and when a constraint defined but disabled is selected.
>
You realize, I hope, that the only way can Oracle KNOWS that the index contains valid values is to rebuild?

Tags: Database

Similar Questions

  • Order columns (which make up the primary key constraint) matter in where clause of DML query for use of indexing mechanism to operate.

    Version of DB: database Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production


    I have a table my_table as below:
    create table my_table
    (
    my_code varchar2 (6).
    my_id varchar2 (24).
    forced pk_1 primary key (my_code, my_id)
    );


    Primary_key here's a composite key that contains columns 1 (my_code) and 2 (my_id).
    Is there that a difference in the way below queries is executed in terms of performance (use of indexing in the extraction).

    (a) select * from my_table where my_code = '123' and my_id = "456";
    (b) select * from my_table where my_id = '456' and my_code = '123';


    The understanding I have the order of the column in the where clause should be identical to the sequence in
    What primary key draws for indexing to be used by oracle in oracle other DML queries ignores indexing
    However when I used explain plain both show the same query cost with single scan with index rowid.
    so I don't know if I'm wrong in the concept that I have. Kindly help.

    Thanks in advance,
    Gerard

    Your question is answered in the Performance Tuning Guide

    Using indexes and clusters

    14.1.4 choosing composite indexes

    A composite index contains several key columns. Composite indexes can provide additional benefits compared to the index to single column:

    • Improved selectivity

      Sometimes the two or more columns or expressions, each with a low selectivity can be combined to form a composite with a high selectivity.

    • Reduced IO

      If all columns selected by a query are a composite index, then Oracle may return these values in the index without access to the table.

    A SQL statement can use a path on a composite index if the statement contains constructions that use a main part of the index.

    Note:

    This is no longer the case with the skip index scans. See "Index Skip Scans".

    A main part of an index is a set of one or more columns that have been specified first and consecutively in the list of columns in the CREATE INDEX statement that created the index.

  • blocking because of the primary key constraint

    Hi all

    Recently, we migrated to 9.2.0.4 to 10.2.0.4. In the new version of oracle there was a strange behavior, we have 200 + oracle database user and there was too much blocking on a particular one table, we looked and looked for the cause but found nothing exact reason, then on the internet somewhere, we found that if a primary key is disabled and no there is also foreign then blocking is caused for example

    CREATE TABLE TEST_MST
    (
    MST_COL1 NUMBER,
    MST_COL2 NUMBER,
    MST_COL3 NUMBER
    )

    CREATE TABLE TEST_DTL
    (
    MST_COL1 NUMBER,
    MST_COL2 NUMBER,
    MST_COL3 NUMBER,
    DTL_COL1 NUMBER,
    DTL_COL2 NUMBER,
    DTL_COL3 NUMBER
    )

    ALTER TABLE TEST_MST ADD)
    CONSTRAINT PK_TM
    KEY ELEMENTARY SCHOOL
    (MST_COL1, MST_COL2, MST_COL3)) ;

    ALTER TABLE TEST_DTL ADD)
    CONSTRAINT PK_TD
    KEY ELEMENTARY SCHOOL
    (MST_COL1, MST_COL2, MST_COL3, DTL_COL1, DTL_COL2)) ;

    ALTER TABLE TEST_DTL ADD)
    CONSTRAINT FK_TM_TD
    FOREIGN KEY (MST_COL1, MST_COL2, MST_COL3)
    REFERENCES TEST_MST (MST_COL1, MST_COL2, MST_COL3));

    ALTER TABLE TEST_DTL
    DISABLE THE CONSTRAINT PK_TD;


    so, I just want to be sure that's the exact reason only blocking sessions and if yes, then why not so happning.

    Thanks and Rgds,
    Piyush
  • creating a unique index of instaed of using the primary key index

    Hello

    I heard in a debate sometimes it is better to create a unique index on a column and use it instead of using the primary key index in oracle. I did not understand what that the reason propely.

    Can someone please help me in this topic if it is valid.

    Thanks in advance

    On the surface, which does not seem reasonable... Volume of the DML is irrelevent to determine which column is the primary key for a table.

    My wild speculation a bit at a reasonable time could someone do...

    If you use synthetic primary keys (i.e. the keys generated by sequence) and that your tables are subject to large volumes of inserts such as there is a danger that the block "to the right" will be the source of contention block and worry not about analysis of beach on the column, you can create a reverse on this column (unique or non-unique) key index before creating the primary key constraint and to indicate Oracle to use this existing index to respect the primary key constraint.

    Obviously, however, this involves a lot of assumptions to arrive at a reasonable point. There may well be another set of assumptions that could also lead to a valid argument. Or it could be a myth that someone has heard and just repeats.

    Justin

  • Direct path SQLLDR allows duplicates in the primary key

    I would use sqlldr path direct to charge millions of records in the table but direct way allows duplicates on the primary key constraints.

    inserts of duplicates
    sqlldr control deploy_ctl/deploy_ctl@dba01mdm = direct ctl_test.ctl = true
    primary key is enabled

    I do not understand the behavior that's why the primary key is always enabled--(logiquement il doit avoir désactivé que doublons insérés)

    Inserts no duplicates
    sqlldr control = ctl_test.ctl deploy_ctl/deploy_ctl@dba01mdm
    primary key is enabled

    Please can I know if there is any work around to use direct path with constraints of primary school in place.

    The only solution is to not use direct load, if your dataset contains records in duplicate, of the documentation:

    /*
    A record that violates a UNIQUE constraint is not rejected (the file is not available in the memory when the constraint violation is detected).
    */

  • Automatically fill the primary key

    We have Oracle database 10g. I've added a primary key column to my deo_language_resources_t of table with the following logic:

    -- 1. create sequences
    create sequences eod_lr_seq
    Start increment by 10 by 5
    MinValue 10 nomaxvalue
    NoCache;

    -- 2. Create the primary key column
    ALTER table deo_language_resources_t
    ADD NUMBER RESOURCE_ID;

    -- 3. Fill the pk
    Update deo_language_resources_t
    Set id_ressource = eod_lr_seq.nextval
    where id_ressource is null;

    -- 3. Create the primary key constraint
    ALTER table deo_language_resources_t
    Add constraint resource_id_pk key (resource_id) primary;

    insert into deo_language_resources_t
    (first_name, last_name, id_ressource)
    values ('John', 'Doe', eod_lr_seq.nextval);

    The last INSERT statement successfully a line inserted into the table and populated by id_ressource with the next number in the sequence eod_lr_seq. Ok.

    Is it possible to set a constraint on deo_language_resource_t so that when I INSERT a line the id_ressource is automatically set to eod_lr_seq.nextval? It is possible to define a trigger and resembling the logic of the trigger? The insert statement would be like:

    INSERT INTO deo_language_resources_t (first_name, last_name) VALUES ('John', 'Doe');
    create trigger deo_language_resources_trigger
    before insert on deo_language_resources_t
    for each row
    begin
    select eod_lr_seq.nextval into :resource_id from dual;
    end;
    
  • Create the primary key on the target

    Y at - it no IKM which would create the primary key on target after having read the instructions for the source?

    Thank you
    Dinesh.

    Hi Dinesh,

    You can customize a KM to create a primary key on the target
    The target table will be created with the mention of the primary key constraint in the data target store.

    Steps: -.

    Customiuse creating target step of the table and I create $ step table.

    for example: -.

    original train target table KM walk (IKM Oracle Simple incremental update): -.

    create table< %="snpRef.getTable" ("l",="" "a",="" "targ_name")="" %="">
    (
         <%=snpRef.getTargetColList("", "[COL_NAME]\t[DEST_CRE_DT] NULL", ",\n\t", "")%>
    )

    custom STAGE: -.

    create table< %="snpRef.getTable" ("l",="" "a",="" "targ_name")="" %="">
    (
         <%=snpRef.getTargetColList("", "[COL_NAME]\t[DEST_CRE_DT] NULL", ",\n\t", "")%>

    CONSTRAINT constraint_name PRIMARY KEY (< %="snpRef.getColList" ("",="" "[column]",="" ",",="" "",="" "pk")="" %="">)
    )

    Note:- The code above described here is just a sample of reference. I did not test the syntax.

    Kind regards
    Its

  • The index of the primary key in a different tablespace.

    Hello

    I have a user PROD. It has received a tablespace PROD_TBS default.
    There is a separate table for all indexes space in the diagram, PROD_IDX.

    I want to create a TEST table as follows,

    CREATE TABLE TEST
    (TEST_ID, NUMBER (1),)
    NAME VARCHAR2 (10));

    It must be a primary key on the column test_id, but such that the corresponding unique index created by default because of the primary key must be created in the PROD_IDX tablespace.

    How to do this?

    Alternative solution:

    CREATE TABLE TEST
    (TEST_ID NUMBER(1),
    NAME VARCHAR2 (10),
    constraint test_pk primary key (test_id)
    using index tablespace prod_idx
     );
    

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

  • Disable the unique key constraint

    Hello

    Is it possible to disable a unique key constraint?
    I tried the following code:

    ALTER TABLE table_name
    DISABLE the CONSTRAINT uk_constraint_name

    that seems to work fine, but when I try to insert or update a record that the unique constraint is still on. However, Toad in the United Kingdom is marked as disabled.

    What do I need to drop the UK and re-create it after my updates?

    Thank you

    The behavior that I have demonstrated that during
    a. you have an existing UNIQUE Index
    b. you add a Unique key constraint (with the same or another name, any - except that the error message contains the name of the index is different, if the constraint is disabled)

    OTOH, if you set the Unique key on the table without pre-existing index constraint, Oracle creates an Index. If you disable this constraint, Oracle removes the Index.
    So, if it is a small table and you can afford to recreate the Index each time, you can follow this method.

    SQL> create table t_2 (col_1 number, col_2 varchar2(5));
    
    Table created.
    
    SQL> alter table t_2 add constraint t_2_uk unique (col_1);
    
    Table altered.
    
    SQL> select index_name, uniqueness, status from user_indexes where table_name = 'T_2';
    
    INDEX_NAME                     UNIQUENES STATUS
    ------------------------------ --------- --------
    T_2_UK                         UNIQUE    VALID
    
    SQL> insert into t_2 values (1,'a');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> alter table t_2 disable constraint t_2_uk;
    
    Table altered.
    
    SQL> insert into t_2 values (1,'b');
    
    1 row created.
    
    SQL> select index_name, uniqueness, status from user_indexes where table_name = 'T_2';
    
    no rows selected
    
    SQL>SQL> select constraint_name, constraint_type, status from user_constraints where table_name = 'T_2';
    
    CONSTRAINT_NAME                C STATUS
    ------------------------------ - --------
    T_2_UK                         U DISABLED
    
    SQL> alter table t_2 enable constraint t_2_uk;
    alter table t_2 enable constraint t_2_uk
    *
    ERROR at line 1:
    ORA-02299: cannot validate (AWRADMIN.T_2_UK) - duplicate keys found
    
    SQL> delete t_2 where col_2 = 'b';
    
    1 row deleted.
    
    SQL> alter table t_2 enable constraint t_2_uk;
    
    Table altered.
    
    SQL> select index_name, uniqueness, status from user_indexes where table_name = 'T_2';
    
    INDEX_NAME                     UNIQUENES STATUS
    ------------------------------ --------- --------
    T_2_UK                         UNIQUE    VALID
    
    SQL>
    

    Hemant K Collette

  • Factor of clustering for the primary key Index

    Hi all

    I have cretead a new table with 1.7 million records with an index of primary key on ID (NUMBER)
    Number of blocks used is arnd 57 K.

    Factor value of clustering on the primary key index is 1.6 million.

    Could you please suggest what can be the reason for such a clustering factor high for the new table.


    Thank you
    Ash N.

    Google is your friend:
    http://www.dbasupport.com/forums/archive/index.php/t-38893.html
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1032431852141
    http://hemantoracledba.blogspot.com.es/2008/01/impact-of-clustering-factor.html

  • Problem with the primary key and indexes

    Hi all

    I'm looking a mess on one of our main tables.
    One of the developers here added an index on 3 columns in the table, thinking that it would speed up (not noticing that it had not a PK).

    Subsequently another developer has noticed there do not have a primary on key. So they added a touch of primry on the single column.

    The problem is that now the index created on 3 columns is bein used as the primary key index. As when the primary key is created a new index was not created.

    Is there anyway to get rid of this index/change it correct?

    This table is related to many many other tables, so when we tried to remove the index we could not due to the primary key and foreign key violations with other tables.

    Thanks in advance

    Oracle, as you found, is quite capable to use a column enformce multi index a single column primary key, as long as the pk column is the leader in the index. This should not cause performance issues for a search of PK and if the three indexed columns are often selected only may benefit from these types of queries.

    The only way to change that now, would be to drop all CF, drop and add the PK constraint and then add all the FK constraints. A long time and potentially dangerous (if you miss to add back of the FKs) endeavour. Certainly not worth the risk in my opinion.

    John

  • Performance problem on the SQL query that does not use the primary key index

    Hello!

    I have some performance issues on a single SQL query (Oracle 10 g).
    I could solve the problem by using the INDEX indicator, but I would like to know WHY this is happening.

    * Tables *.
    create table jobs)
    ID number (5) not null,
    name varchar2 (100),
    primary key constraint Job_PK (id)
    )
    /
    -Record count: 298

    create table Comp)
    integer ID not null,
    name varchar2 (100),
    primary key constraint Comp_PK (id)
    )
    /
    -Record count: 193

    -Relation m: n
    create table JobComp)
    integer ID not null,
    id_job integer not null,
    id_comp integer not null,
    primary key constraint JobComp_PK (id),
    unique key constraint JobComp_UK (id_job, id_comp),
    Constraint JobComp_FK_Job foreign key (id_job) refers to Job (id),
    Constraint JobComp_FK_Comp foreign key (id_comp) makes reference Comp (id)
    )
    /
    create index JobComp_IX_Comp on JobComp (Cod_Comp)
    /
    create index JobComp_IX_Job on JobComp (Cod_Job)
    /
    -Record count: 6431

    * Ask *.

    When I run this query, the execution plan shows the index using (JobComp_PK and JobComp_IX_Comp).
    No problem.

    Select JobComp.*
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    But when I add the field 'name' of the work table the plan uses full access table to the table of work

    Select JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in the 2.70 dry

    With the help of the index

    Select / * + INDEX (Job Job_PK) * /.
    JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    * Doubt *.

    This behavior is correct?

    PS. : I tried to recalculate the statistics, but nothing changes:

    analyze the job calculation table statistics.
    /
    change the statistical calculation of index Job_PK reconstruction;
    /
    Start
    dbms_utility.analyze_schema (sys_context ('userenv', 'current_schema'), 'CALCULATE');
    end;
    /

    [of]
    Gustavo Ehrhardt

    Gus.EHR wrote:
    Hello.
    I'm sorry for the plan unformatted.
    The execution time of the querys "without field name' and 'with the field name with suspicion" are equal.
    He has no problem caching, because I get the plans of the sequence different from the querys and repeated the performance. The result is always the same.

    I don't think that there is no problem with oracle crossing LOOP IMBRIQUEE to the HASH JOIN when you include the field name and this should be the expected behavior. But it seems that your WORKING table has a degree of parallelism set against what is causing the query to run in parallel (as JOB table is now available with full table scan, instead of indexed access earlier). It could be that the parallel execution is contributor to extra Runtime.
    (a) do you know why the degree of parallelism on the WORK table has been defined? Do you need it?

    You can see if the following query provides a better response time?

    select /*+ NOPARALLEL(JOB) */ JobComp.*, Job.Name
      from JobComp
      join Job
        on Job.id = JobComp.id_job
     where JobComp.id_comp = 134
    
  • Make required error appears only the primary key generated in prior Database Table insert trigger

    Dear all,

    I am a beginner in the ADF and am under Jdeveloper Studio Edition Version 12.2.1.0.0.


    I'm trying to insert a record, I created the trigger for insertion prior to get the primary key and set some other default values.


    On the page, I did read-only primary key column and false required.


    When I try to save - commit (Programmatic), I get errors for the required value. How can I stop this errors.


    Secondly, I also tried changing the agent to disabled on the attribute View object that raised the error below:


    < oracle.dfw.impl.incident.DiagnosticsDataExtractorImpl > < DiagnosticsDataExtractorImpl > < createADRIncident > < incident created 148 to key problem "DFW-99998 [oracle.jbo.PersistenceException] [oracle.jbo.server.RowReference.verifyPrimaryKeys] [Proposals]" >


    Hoping for help.


    Thanks and greetings


    Arif Khadas

    If the primary key values from DB sequence, you can follow this approach:

    Using the sequence of database in ADF - Souza Waslley Blog

    Oracle Fusion Middleware Technologies: ADF 11 G: generate the primary key sequence number

    Otherwise, instead of DB trigger, create the DB function that retrieves the value of the PK and call stored function in the overloaded method create() entity:

  • How did the foreign key that is recognized by the primary key

    Hi, when I have two user tables and userLevel and the primary key of the user is the user name and I add a field to userLevel userID is only to make the userID field in userLevel automatically the foreign key of the table? Or do you switch the engine of MyISAM tables to InnoDB to make relational links. Can someone please explain this in English clear to me, because I just can't get my head around this.

    In the case of a query such as SELECT statement, we talked, being a key actually means that the field is indexed so that the database can quickly look up.  Thus, in phpMyAdmin, you set the field to be indexed by the visualization of the structure of the table and clicking the icon index (the one with the Lightning) for the field in the Action section.

    If you are looking for integrity refrential between tables we also talked about and using the InnoDB engine, you can click the link 'Show the relational' in the table structure page of phpMyAdmin and define foreign key constraints.

  • Shape of the apex - how to get the primary key value manually?

    Hello

    Whenever I create form by using wizard Apex, he asks me to specify the trigger/sequence/pl/sql function to fill the primary key value.

    However, if I want to specify primary key myself (ie. undetermined generated automatically), how I can clarify that?

    Thanx

    Hello

    You mean by yourself: by hand or by a pl/sql?

    If you say by trigger, the system does not take on what number is sent. If you can give it "manually".

    May I ask what is the reason for this?

    See you soon,.

    Arnaud

Maybe you are looking for

  • HOW TO OPEN WITH FIREFOX GMAIL

    Quite a while each time I open Firefox my gmail account would be open with it in a new tab. For some reason this happens more and I would get firfox for do it again

  • B540 TDR and black screen on startup

    Hi all, I bought a B540 in April a power works fine until end of July when it began to show the error "display driver has stopped working and has recovered." a few days later I let him (I have need as a wifi station to connect devices remove) and aft

  • I have to sign each time that I will go to my hotmail it's because of my firewall

    I sign every time that I go to my hotmail.com .even if I check Disable the box connect

  • Send the menu item for OS6

    Hey, help me please... I sendmenu sourcecode of blackberry Web site, I try to my BB tour 2 (9650) with operating system version 6 does not work... import net.rim.blackberry.api.sendmenu.*; import net.rim.device.api.ui.Field; import net.rim.device.api

  • The quick menu icons?

    Hello I'm not sure what it's called but in OS7 and, possibly, OS6 when you click the trackpad a menu appears. For example in the application in a chat message if you press the trackpad a menu comes up with 'send' and other options. These options have