June 13, 2011

Difference between alias and synonym in sql

Difference between  alias and synonym in sql

Both are different in all manner not only syntactically Synonym is
1. It is a database object
2. It may be Public or private
3. It is permanent until dropped
4. create [public] synonyms syn_name for [Existed database object]; like create synonym emp1  for hr.employees;
Alias is
1. It is not a database object.
2. It will alway private to query
3. It temporary to that query.It to used to provide a name It is generally used to provide a meaning-full heading or column name or table name that is long or inconvenient to type in Query
4. take a example
select rownum as rank,e.* from emp1 e;
here rank and e is alias where as emp1 is synonym

No comments:

Post a Comment