重點 :
- ID為GUID是T1資料表的Primary Key,指定為非叢集索引
- a1,a2不會重複的欄位設定為叢集索引
CREATE TABLE [dbo].[T1]
(
[ID_Key] uniqueidentifier DEFAULT NEWSEQUENTIALID() NOT NULL,
[a1] [nvarchar](10) NOT NULL,
[a2] [nvarchar](10) NOT NULL,
[a3] [nvarchar](10) NULL,
[a4] [datetime] NULL,
[a5] [datetime] NULL,
[a6] [decimal](12, 4) NULL,
[a7] [nvarchar](10) NULL,
[a8] [nvarchar](10) NULL,
[a9] [decimal](12, 4) NULL,
CONSTRAINT [PK_T1] PRIMARY KEY NONCLUSTERED
(
ID_Key ASC
))
CREATE CLUSTERED INDEX CL01 ON T1(a1,a2 asc)
參考資料 :
http://blog.darkthread.net/post-2016-01-29-guid-as-pk-on-db.aspx
沒有留言:
張貼留言