Tuesday, July 30, 2013

Synonym in oracle

You are logged in to database using sys user

and you wanted to retrieve the hr tables.

there are two ways

1>you can call the hr table by prefixing the table name with hr

i.e if you have to refer employee table.

you can do select * from hr.employees.


Or you can define a synonym

create PUBLIC synonym emp for hr.employees

Now you have created a synonym for hr.employees as emp

so in order to retrieve the data from employees table in hr schema you can just execute the below query

select * from emp;

No comments: