0

I am attempting to create synonyms for a user in Oracle.

BEGIN
    FOR S IN (SELECT owner, table_name FROM all_tables WHERE owner = 'TABLE_OWNER') LOOP
        EXECUTE IMMEDIATE 'create synonym '||S.table_name||' for '||S.owner||'.'||S.table_name||'';
    END LOOP;
END;

I get the following error in Toad when executed:

Error at line 1 ORA-00955: name is already used by an existing object ORA-06512: at line 3

Any thoughts?

javanna
  • 59,145
  • 14
  • 144
  • 125
Brian
  • 71
  • 1
  • 2
  • 3

1 Answers1

4

Yes, the table name and owner and the synonym name and owner cannot be the same. Only one object/owner combination may exist. You must either change the owner or the name for the synonym from the table name.

Horus
  • 1,169
  • 9
  • 13
  • 3
    If you are trying to make public synonyms then the command is create public synonym, btw. You are probably running this as the user matching 'TABLE_OWNER', which is causing your problems. – Horus Apr 08 '11 at 15:40