首页 > 代码库 > SQL自增长的数据插入

SQL自增长的数据插入

--子增长的插入
/*创建表*/
create table teacher
(
id int identity(1,1) primary key not null,
name varchar(20)
)

select * from teacher

/*关闭自增长*/
SET IDENTITY_INSERT teacher on

insert into teacher(id,name) values(2000,‘guo‘)

/*打开自增长*/
SET IDENTITY_INSERT teacher off

insert into teacher(name) values(‘guo‘)