Home Oracle Commands

CREATE SYNONYM

Create a synonym.

Syntax:

   CREATE [OR REPLACE] [PUBLIC] SYNONYM [schema.]synonym 
      FOR [schema.]object [@dblink]

'PUBLIC' will create a public synonym, accessible to all users (with the appropriate privileges.)

Unlike Views, Synonyms do not need to be recompiled when the underlying table is redefined.

There is a small performance hit when accessing data through a public synonym.

Oracle will resolve object names in the following order:

current user
private synonym
public synonym

An alternative method to access data in another schema is to use:

ALTER SESSION set current_schema = Other_Schema

"A synonym is a word you use when you can't spell the word you first thought of" - Burt Bacharach

Related Commands:

DROP SYNONYM
CREATE VIEW

Commands that can use synonyms:

AUDIT
COMMENT
DELETE
EXPLAIN PLAN
GRANT
INSERT
LOCK TABLE
NOAUDIT
REVOKE
SELECT
UPDATE

Related Views:

 DBA_SYNONYMS         ALL_SYNONYMS         USER_SYNONYMS      PUBLICSYN



Back to the Top

Simon Sheppard
SS64.com