Email Us : sunilkumark11@gmail.com
Free Training > SQL PL/ SQL Forms Reports Oracle Applications
< Previous Next >

 
SQL 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;

 

 

< Previous Next >