To create a private synonym in another user's schema, you must have CREATE ANY SYNONYM system privilege. If you are using Trusted Oracle7 in DBMS MAC mode, your DBMS label must dominate the creation label of the owner of schema to contain the synonym.
To create a PUBLIC synonym, you must have CREATE PUBLIC SYNONYM system privilege.
PUBLIC
schema
is the schema to contain the synonym. If you omit schema, Oracle7 creates the synonym in your own schema. You cannot specify schema if you have specified PUBLIC.
synonym
is the name of the synonym to be created.
FOR
identifies the object for which the synonym is created. If you do not qualify object with schema, Oracle7 assumes that the object is in your own schema. The object can be of the following types:
The object cannot be contained in a package.
Note that the object need not currently exist and you need not have privileges to access the object.
You can use a complete or partial dblink to create a synonym for an object on a remote database where the object is located. For more information on referring to database links, see the section, "Referring to Objects in Remote Databases," . If you specify dblink and omit schema, the synonym refers to an object in the schema specified by the database link. It is recommended that you specify the schema containing the object in the remote database.
If you omit dblink, Oracle7 assumes the object is located on the local database.
A synonym can be used to stand for its base object in any of the following Data Manipulation Language statements:
SELECT *
FROM dept
To retrieve rows from BLAKE.DEPT, the user SCOTT must preface DEPT with the schema name:
SELECT *
FROM blake.dept
If the user ADAM's schema does not contain an object named DEPT, then ADAM can access the DEPT table in BLAKE's schema by using the public synonym DEPT:
SELECT *
FROM dept
Example I
CREATE SYNONYM market
FOR scott.market_research
Example II
To create a PUBLIC synonym for the EMP table in the schema SCOTT on the remote SALES database, you could issue the following statement:
CREATE PUBLIC SYNONYM emp
FOR scott.emp@sales
Note that a synonym may have the same name as the base table provided the base table is contained in another schema.