本文介紹了創建 SQL 身份作為主鍵?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
create table ImagenesUsuario
{
idImagen int primary key not null IDENTITY
}
這不起作用.我該怎么做?
This doesn't work. How can I do this?
推薦答案
只需對語法進行簡單的更改即可:
Simple change to syntax is all that is needed:
create table ImagenesUsuario (
idImagen int not null identity(1,1) primary key
)
通過顯式使用constraint"關鍵字,您可以為主鍵約束指定一個特定名稱,而不是依賴 SQL Server 自動分配名稱:
By explicitly using the "constraint" keyword, you can give the primary key constraint a particular name rather than depending on SQL Server to auto-assign a name:
create table ImagenesUsuario (
idImagen int not null identity(1,1) constraint pk_ImagenesUsario primary key
)
如果根據您對表的使用情況最有意義,請添加CLUSTERED"關鍵字(即,搜索特定 idImagen 和寫入量的平衡超過了通過其他索引對表進行聚類的好處).
Add the "CLUSTERED" keyword if that makes the most sense based on your use of the table (i.e., the balance of searches for a particular idImagen and amount of writing outweighs the benefits of clustering the table by some other index).
這篇關于創建 SQL 身份作為主鍵?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!