Home » SQL & PL/SQL » SQL & PL/SQL » Problem with recreate table with primary key constraint
Problem with recreate table with primary key constraint [message #189353] Thu, 24 August 2006 04:37 Go to next message
EdwinK
Messages: 2
Registered: August 2006
Junior Member
Hi All,

I just tried to create a table in Oracle such as:
CREATE TABLE t1
( 
    empno numeric(3, 0) not null,
    CONSTRAINT pk_empno PRIMARY KEY(empno));


then i dropped:
DROP TABLE t1


afterwards i tried to create again and the error raised up:
CREATE TABLE t1
( 
    empno numeric(3, 0) not null,
    CONSTRAINT pk_empno PRIMARY KEY(empno));
constraint pk_empno primary key(empno))
ORA-02264: name already used by an existing constraint


Thanks in advanced to anyone who help me regarding this problem

Regards,
Edwin
Re: Problem with recreate table with primary key constraint [message #189354 is a reply to message #189353] Thu, 24 August 2006 04:40 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
To check which table has the constraint execute the following query:

select table_name
from   user_constraints
where  constraint_name = 'PK_EMPNO'
/
Re: Problem with recreate table with primary key constraint [message #189355 is a reply to message #189353] Thu, 24 August 2006 04:40 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You've used that constraint name somewhere else in the meantime.

Run this query to find out where:
SELECT table_name
FROM   all_constraints
WHERE  constraint_name = 'PK_EMPNO';
Re: Problem with recreate table with primary key constraint [message #189362 is a reply to message #189355] Thu, 24 August 2006 04:50 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Grin
Re: Problem with recreate table with primary key constraint [message #189364 is a reply to message #189362] Thu, 24 August 2006 04:55 Go to previous message
EdwinK
Messages: 2
Registered: August 2006
Junior Member
Yes it solved, you are correct there was somewhere a constraint named pk_empno Laughing.

Frank and JRowBottom, thanks for your kindly and quick response.
Previous Topic: date differences from one table
Next Topic: Retrieve data from a table based on column name specified in another table.
Goto Forum:
  


Current Time: Sun Dec 04 15:04:33 CST 2016

Total time taken to generate the page: 0.04550 seconds