Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 643757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:19:03+00:00 2026-05-13T21:19:03+00:00

I had a constraint in a table CREATE TABLE USERSAPPLICATIONS ( USERID NUMBER NOT

  • 0

I had a constraint in a table


CREATE TABLE "USERSAPPLICATIONS" (
    "USERID" NUMBER NOT NULL ,
    "APPLICATIONNAME" VARCHAR2 (30) NOT NULL ,
 CONSTRAINT "PK_USERSAPPLICATIONS" PRIMARY KEY ("USERID","APPLICATIONNAME") 
) 
/

Two weeks ago I modified the table, added some columns, deleted the constraint “PK_USERSAPPLICATIONS” and added a surrogate key. I can see in Oracle SQL Developer that the constraint PK_USERSAPPLICATIONS does not exist anymore.

Regardless of that, when I try to add two entries with the same userid/applicationName combination, I get an error


SQL Error: ORA-00001: unique constraint (ACCOUNTMP1.PK_USERSAPPLICATIONS) violated
00001. 00000 -  "unique constraint (%s.%s) violated"
*Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
           For Trusted Oracle configured in DBMS MAC mode, you may see
           this message if a duplicate entry exists at a different level.
*Action:   Either remove the unique restriction or do not insert the key.

When I execute the statement


SELECT *
FROM   user_cons_columns
WHERE  constraint_name = 'PK_USERSAPPLICATIONS' 

I get zero rows. How can that be? Oracle shouldn’t have any knowledge of the constraint PK_USERSAPPLICATIONS as it has been deleted already weeks ago, and I cannot see it in the database either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:19:03+00:00Added an answer on May 13, 2026 at 9:19 pm

    Do you still have the index which was used by that constraint? Because unless you included the DROP INDEX clause when you dropped the constraint it will still be there. Start with

    SELECT * 
    FROM   user_indexes
    WHERE  index_name = 'PK_USERSAPPLICATIONS'  
    /
    

    Alternatively,

    select index_name 
    from user_indexes
    where table_name = 'USERSAPPLICATIONS'
    and  uniqueness='UNIQUE' 
    /
    

    or

    select index_name 
    from user_ind_columns
    where table_name = 'USERSAPPLICATIONS'
    and  column_name in ('USERID' ,'APPLICATIONNAME')  
    /
    

    edit

    Proof of concept

    SQL> create table t23 (id number not null, alt_key varchar2(10) not null)
      2  /
    
    Table created.
    
    SQL> create unique index t23_idx on t23 (id)
      2  /
    
    Index created.
    
    SQL> alter table t23 add constraint t23_pk primary key (id) using index
      2  /
    
    Table altered.
    
    SQL> insert into t23 values (1, 'SAM I AM')
      2  /
    
    1 row created.
    
    SQL> insert into t23 values (1, 'MR KNOX')
      2  /
    insert into t23 values (1, 'MR KNOX')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (APC.T23_PK) violated
    
    SQL>
    

    So the constraint works. What happens if we drop it, without the DROP INDEX clause?

    SQL> alter table t23 drop constraint t23_pk
      2  /
    
    Table altered.
    
    SQL> insert into t23 values (1, 'MR KNOX')
      2  /
    insert into t23 values (1, 'MR KNOX')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (APC.T23_IDX) violated
    
    
    SQL>
    

    Note the subtle change in the error message. The second failure references the index name, whereas the original message referenced the constraint. If the index name is the same as the constraint name it would be hard to diagnose this.

    If you don’t explicitly pre-create the unique index Oracle’s default behaviour is to create a non-unique index. Consequently, dropping the constraint without dropping the index does not cause this problem. (Caveat this behaviour is true of 11g. I presume – but cannot be sure – that it is also this way in earlier versions).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 388k
  • Answers 388k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try using the same in a console application. A console… May 15, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer So you are trying to send an event from html… May 15, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer Use a selector for the collection, then use index with… May 15, 2026 at 12:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.