Synonyms
A synonym permits a table to referred to by another name. The syntax of the SQL statement to create a synonym is:
CREATE SYNONYM synonym name FOR table_name;
To remove a synonym, the syntax of the statement is:
DROP SYNONYM synonym name;
A synonym is the property of is creator. That is, only that user may drop it.
Synonyms are of limited use. However, they may be used to shorten the amount of entry required when referring to other databases when the OnLine Engine is in use. As the only method of querying any database on the system other than the active database is to refer to the required table as:
database:owner.table
Furthermore, for distributed databases, the reference to a table grows to include the name of the server on which the database is located:
database@servername:owner.table
In such cases, synonyms become convenient items to adopt.
Therefore, rather than have to execute the following type of statement:
SELECT *
FROM stock@warehouse:accmanager.t0007orders, stock@warehouse:accmanager.t0007items
WHERE stock@warehouse:accmanager.t0006orders.c0007id =
stock@warehouse:accmanager.t0007items.c0007id;
With the following synonyms:
CREATE SYNONYM s0006orders FOR stock@warehouse:accmanager.t0006orders;
CREATE SYNONYM s0007items FOR stock@warehouse:accmanager.t0007items;
The above query may be restated as:
SELECT *
FROM s0006orders, s0007items
WHERE s0006orders.c0007id = s0007items.c0007id;