Synonyms are a very powerful feature of Oracle and other SQL-compliant relational database systems. They are used as a database shorthand. They make it possible to shorten the specification of long or complex object names. This is especially useful for shared tables or views. In addition, the use of DATABASE LINKS in synonyms allows transparent access to other databases on other nodes or even other entire systems halfway around the globe.
A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.
Create and drop SYNONYM
SQL> CREATE SYNONYM ShorterNameForEmployee FOR Employee; Synonym created. SQL> select * from ShorterNameForEmployee; ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY ---- ---------- ---------- --------- --------- ---------- ---------- 01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto 02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver 03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver 04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver 05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver 06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York 07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York 08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver 8 rows selected. SQL> DROP SYNONYM ShorterNameForEmployee; Synonym dropped.
No comments:
Post a Comment