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

Tags: Database

Similar Questions

  • 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?

  • Drop partition without disabling the foreign key

    Hi all

    I have a table parent and child.

    Parent table

    create the table parent_1
    (identification number,
    create_date date,
    Constraint parent_1_pk001 PRIMARY KEY (id))
    PARTITION OF RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION parent_1_part VALUES LESS THAN (January 1, 2010 '));

    Child table
    create the table child_1
    (identification number,
    create_date date,
    Constraint child_1_fk001 FOREIGN KEY (id)
    REFERENCES parent_1 (id))
    PARTITION OF RANGE (create_date)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (PARTITION create_date_part VALUES LESS THAN (January 1, 2010 '));


    I have problems to delete partition.
    Parent_1
    1 JULY 26, 12
    2 JULY 26, 12

    Child_1
    1 JULY 26, 12

    ALTER drop partition table CHILD_1 SYS_P274;
    table altered CHILD_1.

    ON THE PARENT PARTITION A FALL
    ALTER drop partition table parent_1 SYS_P273;

    Error report:
    SQL error: ORA-02266: unique/primary keys in table referenced by foreign keys enabled
    02266 00000 - "unique/primary keys in table referenced by foreign keys enabled.
    * Cause: An attempt was made to truncate a single table or
    primary keys referenced by foreign keys in another table.
    Other unauthorized trades are a drop/truncate partition a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    * Action: Before performing the operations described above, the table, disable the
    constraints foreign key in other tables. You can see what
    constraints are making reference to a table by issuing the following
    command:
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'tabnam ';


    PLEASE KNOW IF THERE IS A WAY TO THE PARENT PARTITION DROP WITHOUT TOGGLE FOREIGN CONSTRAINTS


    Thank you
    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause: An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action: Before performing the above operations the table, disable the
    foreign key constraints in other tables. 
    

    You can do until you disable the foreign key constraint

    http://jonathanlewis.WordPress.com/2006/12/10/drop-parent-partition/

    Hope this helps

    Mohamed Houri
    www.hourim.WordPress.com

  • System to disable the 59628700 key. Please help me

    I don't remember my password for the life of me. Please help me!

    Disable the system key 59628700

    Hello:

    Restart and enter the code:

    46780326

  • Satellite Pro P - how to disable the hot keys for camera assistant?

    Is it possible, and how, to disable the shortcut keys for the camera wizard?

    The default keys interfere with shortcuts of Microsoft Office (Word) - for example Alt + F9 to show/hide codes field to turns on the properties of camera assistant, Alt + 10 screen settings of camera etc.

    I find this very frustrating.

    Hello

    Of course you can turn it off.
    You must remove the software from the camera in msconfig start up.

    So go to start-run-msconfig online online
    Go to the Startup tab and disable the camera software. Restart the computer laptop and that s all!

    Good bye

  • SQL statement error INSERT The conflicted with the FOREIGN KEY constraint

    I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.

    SQL questions are better posed on Technet.  They are better equipped to manage the

    http://social.technet.Microsoft.com/forums/en-us/categories/

  • HP Pavilion dv6 vw882ua #aba: disable the system key 50230606

    Has been workin on my son's cell phone, it was previosly belonging to a member of the family, I went into the BIOs and cleared out the Admin password by changing it to empty, then it would be not be displayed to the power upward. Today, it happens during the power upward and doesn't take anything for a password, tried leaving empty and hit back and get a system to disable the 50230606 key. No matter how high and far I search I find anything on the Internet about this issue of key, please help as I am panic and highlighting.

    Hello

    Enter: 45198228

    Kind regards

    DP - K

  • How can I disable the SHIFT key

    I am running Windows XP Pro and need a way to disable the SHIFT key. I did not need to disable sticky keys, it's already done. Where to run my keyboards, the SHIFT key causes all sorts of questions, and since it is not necessary, I would like to turn it off completely. Thank you.

    You might want to check

    http://www.usnetizen.com/fix_capslock.php
    http://msdn.Microsoft.com/en-us/goglobal/bb964665.aspx

    Before you begin to modify the Windows registry, save it.  C:\WINDOWS\ERUNT is a good tool for this: http://www.larshederer.homepage.t-online.de/erunt/

  • How to disable the keyboard key window in vista

    no idea how to disable the logo key window? There always lock my program out when I accidentally click on it... I found a link on window XP, but it does not work for vista ( http://support.microsoft.com/kb/216893).

    Pls advise thk

    THK mate. Problem solved.

    http://www.LIUtilities.com/Products/RegistryBooster/tweaklibrary/Tweaks/11212/ step by step solution.

  • Can I disable the product key of Win7 on a laptop stolen?

    I bought a family pack of Windows7 and used a updates on the laptop for my son who was stolen last month.  Can I disable the product key on the laptop and use the key on another pc?

    Unfortunately, no, there is no method available to disable remote a product key.

    because the thief has your computer, even if it were possible, they could just use a retreival key utility and retrieve your product key. Also, this sets up a cat and mouse scenarios, because they could easily re-activate the license using phone activation. Your best option is to use the phone activation and explain carefully the situation in the call that your product key agent and the laptop has been compromised. The might be able to do something. If you had used the encryption, your data could be much safer.

    Activate Windows 7 manually:
    1. click on start and in the search for box type: slui.exe 4

    2. press enter on your keyboard

    3. Select your country.
    4. Select the telephone activation option and brace yourself for a real person.
    http://support.Microsoft.com/kb/950929/en-us

  • Disabling the product key of Windows 8? [guide]

    Hello guys!

    I have a question, if I want to install Windows 8 on another PC how to disable the old key?

    Deutsch:

    Hallo Leute ich hab don't question, wenn ich Windows 8 Pro auf einem other PC installieren will be wie den ich kann Product Key von dem alten Rechner deaktivieren?

    Press the Windows key + X

    Click on command prompt (Admin)
    At the command prompt, type: slmgr.vbs - upk

    Press enter, this will uninstall the product key of the computer and to the evaluation mode, you are now free to use it on another computer. If you experience problems, try to activate by phone:

    1. press the Windows key + X , and then click run, and then type: slui.exe 4

    2. then press the ENTER"" key.

    3. Select your "country" in the list.

    4. choose the option "activate phone".

    5. stay on the phone (do not select/press all options) and wait for a person to help you with the activation.

    6. explain your problem clearly to the support person.

    Installation is currently in trial mode, will need to be activated or it will go into reduced functional mode. You have the option to install another version or edition of Windows or get a product key for it. You can also set the system.

  • Installed by windows error 8 in 2 comp. How to disable the product key/uninstall windows 8 laptop in order to install and use on your PC

    I just bought a new windows 8 CD. It has been stated in the CD that I can use to download/install up to 5 times. So I installed windows 8 to my PC and my laptop. I had matched in the product key to my laptop, after I tried seizes the same product key to my PC, which results in an error whichn I had discovered later that you can only use 1 product key for 1 comp.

    So my dilemma is now I want to use the product key on my PC and not on my laptop. How to disable the product key/uninstall 8 windows in my laptop so I can use the product key on my PC since I use my PC more.

    Also there is a time at which I should activate my windows 8 on my PC? because I'm afraid I'm not able to use it and I will get blocked by microsoft until I can fix this error.

    Please help me on how I can solve this problem.

    Thank you

    Press the Windows key + X

    Click prompt (Admin)

    At the command prompt, type: slmgr.vbs - upk

    Press enter, this will uninstall the product key of the computer and to the evaluation mode, you are now free to use it on another computer.

    On the computer where you want to enable Windows 8, you will need to reactivate by phone:

    1. press the Windows key + X , and then clickrun, and then type: slui.exe 4

    2. then press the ENTER"" key.

    3. Select your "country" in the list.

    4. choose the option "activate phone".

    5. stay on the phone (do not select/press all options) and wait for a person to help you with the activation.

    6. explain your problem clearly to the support person.

  • Can I disable the F1 key for help from Adobe? I want to use the F1 key to open a script that I wrote. I don't want the F1 key to open the Adobe help.

    Can I disable the F1 key for help from Adobe? I want to use the F1 key to open a script that I wrote. I don't want the F1 key to open the Adobe help.

    Edition > keyboard shortcuts

  • How can I disable the unique - Fn key function keys?

    I have a new Dell with Win 7 laptop, and the volume control function keys, reading, etc. when they are pushed to him only (without the need to push the Fn key at the same time).  The problem is that I use these keys only to other purposes more how to adjust the volume, etc.  For example, in MS Publisher, I Zoom in and out to 100% by pressing F9.  However, as it is now I have to press Fn and F9 for this.

    How can I change this back to the 'old' where you need Fn most key to do all what indicates the icon on the function key?  As the volume, check the battery, brightness, etc.

    I searched on help for Win 7 without success.

    Thanks for your help.   Bob

    For any question on Windows 7:

    http://social.answers.Microsoft.com/forums/en-us/category/Windows7

    Link above is Windows 7 Forum for questions on Windows 7.

    Windows 7 questions should be directed to the it.

    You are in the Vista Forums.

    See you soon.

    Mick Murphy - Microsoft partner

  • ODI is recovering not Unique key constraint

    I created a table with script below and reverse engineering it.

    create table test
    (primary_id number,
     unique_not_null_ID number not null,
      col3 number,
     col4 varchar2(200),
     col5 varchar2(2000),
    primary key (primary_id),
    unique (unique_not_null_ID) 
    )
    

    But all looking in the constraint of the data store only the primary key is here

    Also, within the quick edit tab Interface is show

    (1) Primary_id: = UK and CN of check

    (2) Unique_not_null_id: = CN is the Coachman


    So, why there no Unique constraint picked up?


    I think then it will only mark it too fast Edition.

    Hi spear,

    Please note that during standard reverse engineering unique keys are not reverse engineering. Then you need to either do reverse engineering on measurement or add a unique touch to the ODI level.

    https://docs.Oracle.com/CD/E28280_01/integrate.1111/e12643/create_rev_model.htm#ODIDG225

Maybe you are looking for