sql server中的自动递增id [英] auto incrementing id in sql server
本文介绍了sql server中的自动递增id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在表中插入新行时自动增加 SQL Server 中的 id?这个id是表的主键.
How to auto increment an id in SQL Server whenever a new row is inserted in the table? This id is primary key of the table.
推荐答案
您正在寻找 身份.
例如
CREATE TABLE MyTable
(
ID INTEGER IDENTITY(1,1) PRIMARY KEY,
FieldA VARCHAR(10)
)
ID 字段会自动递增,从 1 开始,每次递增 1.
The ID field will auto increment, starting at 1 and increasing by one each time.
这篇关于sql server中的自动递增id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文