個人檔案SQL Server 2005 blogs部落格清單 工具 說明
7月6日

Using SQL SERVER 2005 Synonyms

Synonyms

 

Synonyms are words with the same meaning. In SQL server 2005 synonyms works like a permanent alias.

 

Microsoft SQL Server 2005 introduces the concept of a synonym. A synonym is an alternative name for a schema-scoped object. Client applications can use a single-part name to reference a base object by using a synonym instead of using a two-part, three-part, or four-part name to reference the base object.

A synonym is a database object that serves the following purposes:

  • It provides an alternative name for another database object, referred to as the base object, that can exist on a local or remote server.
  • It provides a layer of abstraction that protects a client application from changes made to the name or location of the base object.

Something to do:

 

1.  Create a table with a very long name

CREATE TABLE [dbo].[myverylonglonglonglongtablename](

                [id] [int] IDENTITY(1,1) NOT NULL,

                [field1] [nchar](10) COLLATE Latin1_General_CI_AS NULL,

 CONSTRAINT [PK_myverylonglonglonglongtablename] PRIMARY KEY CLUSTERED

(

                [id] ASC

)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

2. insert some thing in the table

declare @x int

select @x=0

while @x<>10

begin

select @x=@x+1

INSERT INTO [AdventureWorks].[dbo].[myverylonglonglonglongtablename]

           ([field1])

     VALUES

           ('hellox')

end

 

3.  Use select statement on the table with the long name

 

                Select * from [dbo].[myverylonglonglonglongtablename]

 

4.  create and use the synonyms

 

-- Create a synonym for the Product table in myverylonglonglonglongtablename

CREATE SYNONYM shortname

FOR [dbo].[myverylonglonglonglongtablename]

GO

 

-- Query the  table by using the synonym.

 

select * from shortname

回應 (1)

請稍候...
很抱歉,您輸入的回應過長。請縮短您的回應。
您尚未輸入內容,請再試一次。
很抱歉,目前無法新增您的回應,請稍後再試。
若要新增回應,您的父母必須先給您權限。要求權限
您的家長已關閉回應功能。
很抱歉,目前無法刪除您的回應,請稍後再試。
您已超過每日回應上限次數,請於 24 小時後再試一次。
由於系統顯示您可能傳送垃圾郵件給其他使用者,因此您帳號中的回應功能已遭停用。 如果您認為自己帳號遭錯誤停用,請連絡 Windows Live 支援
請完成下列安全檢查,以完成回應。
您輸入的安全檢查字元必須與圖片或音訊中的字元相符。

若要新增回應,請以您的 Windows Live ID 登入 (若您使用 Hotmail、Messenger 或 Xbox LIVE,則您已擁有 Windows Live ID)。登入


沒有 Windows Live ID?註冊

<a href="http://www.rmt-wm.com">RMT-WM</a> <a href="http://rmtvip.jp">rmtvip</a>The baby eagle liked the nest. 「<a href="http://www.rmt-wm.com/games/aion.html">-aion rmt</a>」It was the only world he had ever known. <a href="http://www.rmtvip.jp/game/aion.html">aion RMT</a> It was warm and comfortable, had a great view, 「<a href="http://www.rmt-wm.com/games/0003.html"> リネージュ2 rmt</a> and even better, he had all the food and love and attention that a great mother eagle could provide. <a href="http://www.rmtvip.jp/game/Lineage2_リネージュ2_RMT.html">リネージュ2 RMT</a> Many times each day the mother would swoop down from the sky and land in the nest and feed the baby eagle delicious morsels of food. She was like a god to him, he had no where she came from or how she worked her magic. <a href="http://www.rmt-wm.com/games/A004.html">アラド戦記 rmt</a>The baby eagle was hungry all the time, but the mother eagle would always come just in time with the food and love and attention he craved. The baby eagle grew strong. <a href="http://www.rmtvip.jp/game/アラド戦記_RMT.html">アラド戦記 RMT</a>His vision grew very sharp. He felt good all the time. <a href="http://www.rmt-wm.com/games/0005.html">ff11 rmt</a>Until one day, the mother stopped coming to the nest. <a href="http://www.rmtvip.jp/game/FF11_FFXI_RMT.html">FF11 RMT</a>Thelooked up at the mother and cried "Why did you abandon me? I'm going to die any minute. How could you do faster. He screamed. "I'm dying I'm dying," he cried. He picked up more speed. <a href="http://www.replica-watches-mall.com">Replica Watche</a>
He looked up at his mother. "How could you do this to me?" He looked down. Something strange happens.
9 月 26 日

引用通告

此內容的引用通告是:
http://joeydjs-sql2k5.spaces.live.com/blog/cns!418E3F917301E76D!145.trak
引述這則內容的部落格