Home > Enterprise >  ORA-02264: name already used by an existing constraint (error)
ORA-02264: name already used by an existing constraint (error)

Time:03-22

CREATE TABLE Flight (
FlightNo int NOT NULL PRIMARY KEY,
FlightDate Date,
PlaneSerialNo int,
EmployeeID int,
RouteNo int,
CONSTRAINT FK_PlaneSerialNo FOREIGN KEY(PlaneSerialNo)
REFERENCES Plane(PlaneSerialNo),
CONSTRAINT FK_EmployeeID FOREIGN KEY(EmployeeID)
REFERENCES Employee(EmployeeID),
CONSTRAINT FK_RouteNo FOREIGN KEY(RouteNo)
REFERENCES Route(RouteNo)
);

trying to create a sort of database system using oracle where it tracks flights but it just says the name is already used but havent seen any similarities in constraints other than identifying FKs

CodePudding user response:

Oracle doesn't rely much on similarities - it has found object with exactly the same name in its dictionary and - as you can't have two objects with the same name - it raised the error.

Query user_constraints (and then user_objects, if previous search didn't find anything).

CodePudding user response:

If you want to find out which table it is, you might try

select owner, table_name from dba_constraints where constraint_name = '<some value from your create table command>';

  • Related