"ORA-00955: name is already used by an existing Object" error

Asked

Viewed 87 times

0

When I try to run this part of my code in Oracle Live SQL, it gives the error "name already assigned to existing object". But there are no repeated names here, other than my primary and foreign keys. Can anyone help me find the error?

CREATE TABLE TB_PROVA (
ID_PROVA INTEGER PRIMARY KEY,
DT_PROVA DATE,
NM_SITUACAO VARCHAR(255),
ID_CIRCUITO INTEGER,
CONSTRAINT FK_CIPR FOREIGN KEY (ID_CIRCUITO) REFERENCES TB_CIRCUITO (ID_CIRCUITO) );
  • check again, if the message says that there must already be an object, it can be the table "TB_PROVA" or the FK "FK_CIPR", try changing the names to confirm

  • Select * from dba_objects ...

  • Even if I just run this part of the code (this single table) it gives this error. As if inside this table I have 2 objects with equal names.

  • Try it like this and tell me if it worked: CREATE TABLE TB_PROVA_NOVA (
ID_PROVA INTEGER PRIMARY KEY,
DT_PROVA DATE,
NM_SITUACAO VARCHAR(255),
ID_CIRCUITO INTEGER,
CONSTRAINT FK_CIPR_2 FOREIGN KEY (ID_CIRCUITO) REFERENCES TB_CIRCUITO (ID_CIRCUITO) );

1 answer

1

Can someone help me find the mistake?

The error is that there is already a table with this name TB_PROVA .

Run to check if the table already exists:

Select * from TB_PROVA;

To recreate a table, you need to delete the existing table.

When a table with the same name already exists, the error is:

ORA-00955: name is already used by an existing object

When there already is one constraint the mistake will be:

ORA-02264: name already used by an existing constraint

If the error was already existing column, the error displayed would be:

ORA-00957: duplicate column name

Delete table
If you wish to delete the existing table with the intention of recreating it:

DROP TABLE TB_PROVA

You can see the Fiddle simulation, go to: http://sqlfiddle.com/#! 4/8f5b9/2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.