开发者

INDEX NAME on PRIMARY KEY

I would like create a table and add to it a Primary Key.

As for m开发者_StackOverflow社区y understanding MS SQL add a clustered Index on the Primary Key and will name it with a default name.

I would like to know if is possible create a table and ASSIGN a custom name for the index created by default or how can i change the default name after the table as been created.

Thanks!


Sure - you can define the PRIMARY KEY constraint in your CREATE TABLE statement.

This will generate the default PRIMARY KEY

CREATE TABLE dbo.Table
  (ID INT IDENTITY PRIMARY KEY,
    .......)

but you can totally define the name of the constraint, too:

CREATE TABLE dbo.Table2
  (ID INT IDENTITY CONSTRAINT PK_Table2 PRIMARY KEY,
    ......)


When you create a Clustered Primary Key, you do´nt create a index, but a Table organized as index.

Clustered Primary key is default option when you create a table with primary key on SqlServer.

http://msdn.microsoft.com/en-us/library/aa933131(SQL.80).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜