SQL Server creating table with clustered index without a primary key

前端 未结 3 1421
时光说笑
时光说笑 2021-02-04 02:58

Is it possible to create a clustered index from a create table statement in SQL Server 2008 that is not a primary key?

The purpose of this is for a table in SQL Azure,

3条回答
  •  一向
    一向 (楼主)
    2021-02-04 03:32

    CREATE TABLE dbo.Table_1
        (
        Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
        SomeOtherUniqueColumn int NOT NULL CONSTRAINT Item4 UNIQUE CLUSTERED
    )  ON [PRIMARY]
    

    note the specification of nonclustered on the primary key

    This will still work.

    CREATE TABLE dbo.Table_1
        (
        SomeOtherUniqueColumn int NOT NULL CONSTRAINT Item4 UNIQUE CLUSTERED
    )  ON [PRIMARY]
    

提交回复
热议问题