sql-server – 如何在Create Table中创建非聚簇索引?

Create table Favoritedish    
(    
FavID int identity (1,1) primary key not null,dishID int references dishes(dishID) not null,CelebrityName nvarchar(100)  nonclustered not null     
)

这导致关键字’nonclustered’附近的语法错误.
我引用MSDN帮助创建表语法.我不知道这里有什么问题.

解决方法

在线书籍的帮助事实上提到了CLUSTERED这个关键字,但它只适用于UNIQUE或PRIMARY KEY约束.这两个约束都创建一个索引,您可以指定该索引是聚类还是非聚集.

您不能使用该语法创建标准的非聚簇索引.

Create table Favoritedish    
(    
FavID int identity (1,CelebrityName nvarchar(100)   constraint ux_CelebrityName unique NONCLUSTERED not null     
)

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...