We help IT Professionals succeed at work.

ORA-00955

wasabi3689
wasabi3689 asked
on
I have the following error when I run the sql script

CREATE  SYNONYM abc FOR ABC
                *
ERROR at line 1:
ORA-00955: name is already used by an existing object

In my .sql file
I have the following lines

CREATE  SYNONYM abc FOR ABC;
....
exit;


I think the error is because abc already existed

I want to know how I put a condition to say]

if object abc existed already, need to run

CREATE  SYNONYM abc FOR ABC;

the following statement is correct?

IF NOT EXISTS (abc)
CREATE  SYNONYM abc FOR ABC;
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019
Commented:
The 'object' that exists is the table.  You cannot create a synonym with the same name as the table in the same schema.  If you think about it, does it make sense to do this?

Once you resolve that issue and if the synonym already exists, use 'or replace':
CREATE or replace  SYNONYM my_syn_for_abc FOR ABC;
Top Expert 2011
Commented:
- the error is because that object name is already exists. and you cant use same synonym as the table in the same schema.

- if you want to replace that synonym you can use the following syntax:

CREATE OR REPLACE SYNONYM abcd FOR ABC;
Top Expert 2011

Commented:
- duplicate answer from me. earlier expert have already covers it.
CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
No problem OP, it happens to ALL of us....

Explore More ContentExplore courses, solutions, and other research materials related to this topic.