ORA-00955

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;
wasabi3689Asked:
Who is Participating?
 
slightwv (䄆 Netminder)Connect With a Mentor 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;
0
 
OP_ZaharinConnect With a Mentor 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;
0
 
OP_ZaharinCommented:
- duplicate answer from me. earlier expert have already covers it.
0
 
slightwv (䄆 Netminder) Commented:
No problem OP, it happens to ALL of us....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.