Synonym

From Oracle FAQ
Jump to: navigation, search

A synonym is an alternative name (or alias) for an object (like an table or view) in the database. Objects can have many synonyms. Use the CREATE SYNONYM SQL command to create synonyms and the DROP SYNONYM command to remove them. To get a list of synonyms, query the USER_SYNONYMS view.

Syntax and examples[edit]

Create a synonym - make emp an alias for the scott.employees table:

CREATE SYNONYM emp FOR scott.employees;

Create a public synonym (visible to all DB users):

CREATE PUBLIC SYNONYM dual FOR sys.dual;
CREATE PUBLIC SYNONYM emp FOR scott.employees;

Drop a synonym:

DROP SYNONYM emp;

Drop a public synonym:

DROP PUBLIC SYNONYM emp;

List synonyms in the current schema:

SELECT synonym_name, table_owner, table_name FROM user_synonyms;
Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #