05 SQL Synomyms Imp
05 SQL Synomyms Imp
========
1] A synonym is a database object, which is used as an alias for a table, view or
sequence.
TYPES:
====== 1] PRIVATE 2] PUBLIC
SYNTAX:
=======
Advantages:
============
1] Hide the name and owner of the object.
2] Provides location transparency for remote objects of a distributed database.
And now from �user1� if we wanted to access EMP table that belongs to SCOTT schema
then
we should refer to EMP using �schemaname.tablename� (SCOTT.EMP)
From �user1� if we wanted to hide the EMP table then we should create synonym for
EMP table in �user1�.
/* Inside User1*/
-- Synonym created.
/*Once the synonym is created, we can use this synonym just like a table in select
statement*/
Drop synonym:
=============
-- Synonym dropped.
1] Public Synonym is a synonym which can be accessed by all the users in the
database.
SQL>conn system/admin
Then create a public synonym for EMP table which is in �scott� user.
-- Synonym created.
-- grant succeeded.
Now let�s try to connect to user1 and access the public synonym.
-- Synonym dropped