Email Us : sunilkumark11@gmail.com



SQL
1.
 Introduction
2.
 Commands
3.
 Functions
4.
 Clauses
5.
 Constraints
6.
 Joins
7.
 Sub Queries
8.
 Views
9.
 Indexes
10.
 Sequences
11.
 Synonyms
 

Synonyms


Synonym is an alternate ( extra name ) name given to an object.

Syntax
Create synonym < synonym_name>  for < table_name> ;

Ex
Create  synonym  e1  for  emp;

From now, to access  table emp, we can use the synonym  e1
Like
Select * from   e1;

Insert into e1 ( empno, ename , sal, deptno )  values ( 444,’AAA’, 2000, 10);

We can use synonyms not only for select stmt, for DML commands also.

What is the advantage of creating synonym?
Generally, table name will be long.
Instead of using lengthy tables names in the SQL queries, we can use synonyms.

What is difference between table aliases and  synonyms?
Do you remember, we have learnt table alias concept in joins, which helps in reducing the length of the query.
Table alias is temporary , where as synonym are permanent.

Query to see list of synonyms
Select synonym_name  from user_synonyms;

When you do not want synonym, we can drop it.
Syntax
Drop synonym  < synonym_name> ;

Ex
Drop synonym  e1;