Synonym in Oracle

main Image
A synonyms is an alternative names for any database objects such as tables, views, indexes, sequence etc.

Ques. ==> Difference between synonym and alias?
Ans. ==> Synonyms is permanent alternative for any database object. You can access that database object with that alternative until you drop that synonym but in case of alias it is temporary name used only in query to point any database object by writing alias name after database object name.

Consider example of using alias.

==>Selecting client table

select client

==>Selecting client table using alias

select client using alias

==>Selecting client table using alias only

select client using alias only

Now we will see syntax of synonym and it’s example
Syntax for creating synonym

CREATE SYNONYM synonym_name
FOR object_name;


Example –

Create Synonym C
for client;


creating synonym

Now selecting client table

Select * From client;

selecting client

Now selecting client table using synonym

Select * From C;

select client using synonym

Now inserting data in client table using synonym

Insert into C values (6,’ramesh’);

insert in client using synonym

Now selecting client table

Select * From client;

select client after insertion

NOTE :- Now it is clear that all commands on database objects can be performed using synonym but this cannot be in case of alias.

Syntax for Destroying a Synonym

Drop synonym synonym_name;

Drop synonym C;


drop synonym

Now selecting client using synonym will display error as shown below.

Select * From C;

select client using synonym after dropping

But client table remain as it is with it’s data.

Select * From client;

select client

I hope this article will help you.