Monday, May 9, 2016

Synonym in Oracle

A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.
You generally use synonyms when you are granting access to an object from another schema and you don't want the users to have to worry about knowing which schema owns the object.
CREATE SYNONYM (OR REPLACE)
You may wish to create a synonym so that users do not have to prefix the table name with the schema name when using the table in a query.

Syntax

The syntax to create a synonym in Oracle is:
CREATE [OR REPLACE] [PUBLIC] SYNONYM [schema .] synonym_name
  FOR [schema .] object_name [@ dblink];
SCHEMA: - MOBI_CLEANUP_TEST1
SQL > Create table Test_Table ( id number(10));

SQL > CREATE PUBLIC SYNONYM Test_Synonym_Table
FOR MOBI_CLEANUP_TEST1.Test_Table

SQL > select * from Test_Synonym_Table

SQL > select * from Test_Table

Test_Synonym_Table can be accessed from any other schema without using Schema and dot


No comments:

Post a Comment