Understanding Synonyms

A synonym is an alias for a database object. Synonyms are often used for security and convenience, because they can be used to mask object name and object owner.

In addition, you can use a synonym to simplify SQL statements. Synonyms provide independence in that they permit applications to function without modification regardless of which object a synonym refers to. Synonyms can be used in DML statements and some DDL and TimesTen cache statements.

Synonyms are categorized into two classes:

  • Private synonyms: A private synonym is owned by a specific user and exists in the schema of a specific user. A private synonym shares the same namespace as other object names, such as table names, view names, sequence names, and so on. Therefore, a private synonym cannot have the same name as a table name or a view name in the same schema.

  • Public synonyms: A public synonym is owned by all users and every user in the database can access it. A public synonym is accessible for all users and it does not belong to any user schema. Therefore, a public synonym can have the same name as a private synonym name or a table name.

In order to create and use synonyms, the user must have the correct privileges, which are described in Object Privileges for Synonyms in the Oracle TimesTen In-Memory Database Security Guide.

After synonyms are created, they can be viewed using the following views:

  • SYS.ALL_SYNONYMS: describes the synonyms accessible to the current user. See SYS.ALL_SYNONYMS in the Oracle TimesTen In-Memory Database System Tables and Views Reference.

  • SYS.DBA_SYNONYMS: describes all synonyms in the database. See SYS.DBA_SYNONYMS in the Oracle TimesTen In-Memory Database System Tables and Views Reference.

  • SYS.USER_SYNONYMS: describes the synonyms owned by the current user. See SYS.USER_SYNONYMS in the Oracle TimesTen In-Memory Database System Tables and Views Reference.

The following sections describe using synonyms in TimesTen.