如何在MSSQL中向表中添加PRI和AI等专业?

时间:2021-10-19 18:05:52

I have to be able to connect my C# code to my MSSQL Database. Before I am able to do that I will have to add specialties like PRI and AI to certain columns in the tables.

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

I do not know how to add PRI and AI to certain columns though. I have tried looking in properties and everything, but I can not seem to find a way to add PRI and AI to certain columns.

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

Can someone with knowledge about MSSQL help me out with this? This is what my table looks like:

知道MSSQL的人可以帮我解决这个问题吗?这就是我的表格:

如何在MSSQL中向表中添加PRI和AI等专业?

1 个解决方案

#1


0  

Assuming PRI stands for "primary key" and AI stands for "Automatic increment", to set a primary key, right click on the row and select "Set primary key", to set a column to increment automatically, set "identity specification" = "yes". My suggestion is to skip the designer and write SQL Code instead. That would be:

假设PRI代表“主键”,AI代表“自动增量”,设置主键,右键单击行并选择“设置主键”,将列设置为自动递增,设置“身份规范”= “是”。我的建议是跳过设计器并编写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

#1


0  

Assuming PRI stands for "primary key" and AI stands for "Automatic increment", to set a primary key, right click on the row and select "Set primary key", to set a column to increment automatically, set "identity specification" = "yes". My suggestion is to skip the designer and write SQL Code instead. That would be:

假设PRI代表“主键”,AI代表“自动增量”,设置主键,右键单击行并选择“设置主键”,将列设置为自动递增,设置“身份规范”= “是”。我的建议是跳过设计器并编写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