Synonym in SQL
A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.The syntax for creating a synonym is:
create [or replace] [public] synonym [schema .] synonym_name
for [schema .] object_name [@ dblink];
for [schema .] object_name [@ dblink];
The or replace phrase allows you to recreate the synonym (if it already exists) without having to issue a DROP synonym command.
The public phrase means that the synonym is a public synonym and is accessible to all users. Remember though that the user must first have the appropriate privileges to the object to use the synonym.
The schema phrase is the appropriate schema. If this phrase is omitted, Oracle assumes that you are referring to your own schema.
The object_name phrase is the name of the object for which you are creating the synonym. It can be one of the following:
table | package |
view | materialized view |
sequence | java class schema object |
stored procedure | user-defined object |
function | synonym |
- Mask the real name and owner of a schema object
- Provide global (public) access to a schema object
- Provide location transparency for tables, views, or program units of a remote database.
- Simplify SQL statements for database users
The syntax for dropping a synonym is:
drop [public] synonym [schema .] synonym_name [force];
Very well explained. I can easily prepare my assignment on this topic by taking help from this above shared detail. You have nicely described the meaning and usage of synonyms. Thanks a bunch for this awesome info.
ReplyDelete