How to Fix ORA-00955: Name Is Already Used by an Existing Object in Oracle

Find which object already has the name, and make install scripts repeatable with IF NOT EXISTS and OR REPLACE.

ORA-00955 means a CREATE statement used a name that another object in the same schema already has, in the same namespace. Tables, views, sequences, synonyms, and stored PL/SQL share one namespace, so a view cannot have the name of a table. It usually appears when an install script runs twice. Check what the name belongs to, then reuse, rename, or create the object only if it does not exist.

Reproduce the Error

Example:

create table demo_log (id number);
create table demo_log (id number, msg varchar2(100));
create view demo_log as select 1 as id from dual;          -- tables and views share one namespace

Output:

Table DEMO_LOG created.

Error starting at line : 2
In command -
create table demo_log (id number, msg varchar2(100))
Error report -
ORA-00955: name is already used by an existing object

Error starting at line : 3
In command -
create view demo_log as select 1 as id from dual
Error report -
ORA-00955: name is already used by an existing object

The second table and the view both try to use DEMO_LOG, which the first table has taken.

Fix: Check, or Create Only If Missing

Example:

select object_name, object_type from user_objects where object_name = 'DEMO_LOG';
create table if not exists demo_log (id number, msg varchar2(100));
create index demo_log_id_ix on demo_log (id);

Output:

OBJECT_NAME    OBJECT_TYPE
______________ ______________
DEMO_LOG       TABLE

Table DEMO_LOG created.

Index DEMO_LOG_ID_IX created.

USER_OBJECTS shows what owns the name. CREATE TABLE IF NOT EXISTS does nothing, without an error, when the table is already there, which makes scripts safe to run again. Indexes have a namespace of their own, so an index may even share a table's name, though a distinct name such as DEMO_LOG_ID_IX is clearer.

Things to Know

  • IF NOT EXISTS does not compare definitions: an existing table with different columns is left as it is.
  • CREATE OR REPLACE works for views, PL/SQL, and synonyms, not for tables.
  • A dropped table moves to the recycle bin under a BIN$ name, so it no longer blocks its old name.

Related Guides

Conclusion

ORA-00955 means the name is taken in the schema's namespace. Look it up in USER_OBJECTS, then reuse the object, choose another name, or write DDL with IF NOT EXISTS or OR REPLACE so scripts can run more than once.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted