Synonyms are database objects that point to another object
in the system. They are the aliases for tables, views, sequences, etc. These
are used to hide certain details from the end user. There are two forms of
synonyms – public synonyms which are owned by the public schema and are
available to every user in the database and private synonyms which are present
in the schema of the user who created it, and that user controls who can access
it. The syntax for creating a synonym is:
Listing 3
CREATE PUBLIC SYNONYM DEMO for "ABC"."DEMO";
In the above syntax, ABC is the system name.
Synonyms are used in distributed systems for simplifying the
process of accessing certain data. For example, without using synonyms a SELECT
statement may be written as:
Listing 4
But by using synonyms the above statement may be simplified
as:
Listing 5
As of now, abc.demo is defined as a demo; the user need not
worry for knowing the system name.