DBMS

Synonym

A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.

1) Creating a Synonym :

Syntax:

Create [or replace] [public] synonym [schema .] synonym_name for [schema .] object_name [@ dblink];

The or replace phrase allows you to recreate the synonym (if it already exists) without having to issue a DROP synonym command.
The public phrase means that the synonym is a public synonym and is accessible to all users. Remember though that the user must first have the appropriate privileges to the object to use the synonym.
The schema phrase is the appropriate schema. If this phrase is omitted, Oracle assumes that you are referring to your own schema.
The object_name phrase is the name of the object for which you are creating the synonym.
It can be one of the following:
Table,Package,View,materialized view,Sequence,java class schema object,stored procedure,user-defined object,Function,synonym.

2) destroying a Synonym :

Syntax:

DROP SYNONYM synonymname;

Example:

Run SQL Command Line
SQL> create table test (a number);

Table created.

SQL> create synonym t for test;

Synonym created.

SQL> insert into t values(4);

1 row created.

SQL> insert into t values(5);

1 row created.

SQL> drop synonym t;

Synonym Dropped.
 



Subscribe us on Youtube

Share This Page on


Ask Question