Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of SYNONYM?

What is the use of SYNONYM in SQL Server 2008?

like image 876
Gold Avatar asked Aug 07 '09 17:08

Gold


People also ask

How do you use synonym in a sentence?

In fact his name has become a synonym for the word liar. The words might sound to Jewish ears merely as a synonym for " man." Use the Google synonym search to include synonyms in your strategy.

Where can we use synonyms and antonyms?

Using synonyms makes your speech or writing richer and more "colorful." Using antonyms helps to emphasize your point, show contrast, or explain exactly what you mean. Antonyms too add "colors" to your speech or writing.

What is the use of the word in?

In general, in is used to indicate location or position within or inside something: We went for a swim in the lake. They have a house in the country. Albuquerque is in New Mexico.


1 Answers

In some enterprise systems, you may have to deal with remote objects over which you have no control. For example, a database that is maintained by another department or team.

Synonyms can help you decouple the name and location of the underlying object from your SQL code. That way you can code against a synonym table even if the table you want is moved to a new server/database or renamed.

For example, I could write a query like this:

insert into MyTable (...) select ...  from remoteServer.remoteDatabase.dbo.Employee 

but then if the server, or database, schema, or table changes it would impact my code. Instead I can create a synonym for the remote server and use the synonym instead:

insert into MyTable (...) select ...  from EmployeeSynonym 

If the underlying object changes location or name, I only need to update my synonym to point to the new object.

http://www.mssqltips.com/sqlservertip/1820/use-synonyms-to-abstract-the-location-of-sql-server-database-objects/

like image 103
FistOfFury Avatar answered Sep 22 '22 11:09

FistOfFury