what is synonym in sql ,what is it purpose [Resolved]

Posted by Yugandhar under Sql Server on 8/22/2012 | Points: 10 | Views : 26963 | Status : [Member] | Replies : 9
what is synonym in sql ,what is it purpose
what type of commands we can use




Responses

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Synonyms

1)A synonyms is a single-part name which can replace multi part name in SQL Statement. Use of synonyms cuts down typing long multi part server name and can replace it with one synonyms. It also provides an abstractions layer which will protect SQL statement using synonyms from changes in underlying objects
2)A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.

Create Synonyms :
USE AdventureWorks;
GO
CREATE SYNONYM MyLocation
FOR AdventureWorks.Production.Location;
GO

Use Synonyms :
USE AdventureWorks;
GO
SELECT TOP 5 *
FROM MyLocation;
GO

Drop Synonyms :
USE AdventureWorks;
GO
DROP SYNONYM MyLocation;
GO

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
synonym is a duplicate name of table

server1: emp database name and employee table name

server2 acees this emp table is server1.emp.employee this access the table
select * from server1.emp.employee this access the table
wecan simple create synonym
CREATE SYNONYM S2.EMP FOR SERVER1.EMP.EMPLOYEE
simple select * from S2.EMP EXECUTE THE QUERY

Mahendra
91-9908699686

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Yugandhar on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
thanks nadh123 for ur ans.
can u explain bit more
like
1.what commands we can use on that and if we change the data in synonym ,then what what is effect on the original table
2.it purpose only to simply the name

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
original table effected the data

Mahendra
91-9908699686

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Yugandhar on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
and 2.purpose

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Please mark as answer if it helpful to you..That helps others who search the same..

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Good Work Muhsinathk

Thanks & Regards
Hari

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/17/2012 [Member] Bronze | Points: 25

Up
0
Down
Thanks..

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
you can try the following links....
http://www.dbforums.com/microsoft-sql-server/1667196-how-create-synonym-view-entire-database-tables-view.html

Regards,
Vikash Pathak

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response