在 SSMS 內設定 Primary Key,該 Table 不存在 Clustered Index 的話,預設 Primary Key 就是 Clustered Index,所以要把兩者分開,要先建立 Clustered Index 後再去建立 Primary Key
Step1:Table => 索引 => 新增索引 => 叢集索引
Step2:建立 Primary Key
完成上述兩步驟後來觀察結果
- Step1:建立 Clustered Index (紅線)
- Step2:建立 Primary Key 和 NonClustered Index (綠線)
把該 Table 轉成 Script 來觀察
CREATE TABLE [dbo].[PKSeparate]
(
[ID] [int] NOT NULL,
[Col1] [nchar](10) NULL,
CONSTRAINT [PK_PKSeparate] PRIMARY KEY NONCLUSTERED -- 第一次看到這段 Script
(
[ID] ASC
)W ITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
沒有留言:
張貼留言