Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should database synonyms be used?

I've got the syntax down but I'm wondering if somebody can provide an illustrative use case where database synonyms are very useful.

like image 325
aw crud Avatar asked Mar 02 '10 16:03

aw crud


People also ask

What is the use of database synonyms?

A synonym is a database object that serves the following purposes: Provides an alternative name for another database object, referred to as the base object, that can exist on a local or remote server.

Why do we need synonyms in Oracle?

A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects. You generally use synonyms when you are granting access to an object from another schema and you don't want the users to have to worry about knowing which schema owns the object.

What are two reasons to create synonyms in DBMS?

D. You want to work on your own tables. E. You want to use another schema's tables.


2 Answers

It is excellent for staging mock tables when testing. For example, if your source tables contain millions of records and you want to test a small subset of data, you can use synonyms to re-direct the source table to a smaller table you control so you can stage various scenarios.

In this way, you can update/delete the data in the mock table without affecting your source table. When you are ready to use the source table, all you need to do is re-direct the synonym.

like image 148
Jordan Parmer Avatar answered Sep 21 '22 10:09

Jordan Parmer


Check out the Oracle documentation on synonyms.

In addition to the other answers here, they are also commonly used for:

  • Providing easy to use names for remote tables, i.e. over database links
  • Tables that you need to be accessible to all users, i.e. public synonyms
like image 26
a'r Avatar answered Sep 20 '22 10:09

a'r