Saturday 2 April 2016

SQL Synonym

A synonym is a database object, which is used as an alias for a table, view or sequence.

TYPES
Private
Public

Private synonym is available to the particular user who creates.
Public synonym is created by DBA which is available to all the users.

ADVANTAGES

           Hide the name and owner of the object.
           Provides location transparency for remote objects of a distributed database.

Syntax for Private Synonym

      Create Synonym sysnonym_name for  table_name;

Syntax for Public Synonym

                           Create Synonym Public sysnonym_name for  table_name;

CREATE AND DROP

SQL> create synonym s1 for emp;
SQL> create public synonym s2 for emp;
SQL> drop synonym s1;

No comments:

Post a Comment