如何将 PRI 和 AI 等特性添加到 MSSQL 中的表中?

How can I add specialties like PRI and AI to tables in MSSQL?

我必须能够将我的 C# 代码连接到我的 MSSQL 数据库。在我能够这样做之前,我必须将 PRI 和 AI 等专业添加到 table 中的某些列。

虽然我不知道如何将 PRI 和 AI 添加到某些列。我尝试查看属性和所有内容,但我似乎无法找到将 PRI 和 AI 添加到某些列的方法。

了解 MSSQL 的人可以帮我解决这个问题吗? 这就是我的 table 的样子:

假设PRI代表"primary key",AI代表"Automatic increment", 要设置主键,请右键单击行和 select "Set primary key",要将列设置为自动递增,请设置 "identity specification" = "yes"。 我的建议是跳过设计器并改为编写 SQL 代码。 那将是:

CREATE TABLE Table_1
(
   cit          int identity(1,1) primary key,
   confignaam   varchar(255) null
)

https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-primary-keys https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property