数据库自增长的插入:
1
子增长的插入
2
/*创建表*/
3
create table teacher
4
(
5
id int identity(1,1) primary key not null,
6
name varchar(20)
7
)
8
9
select * from teacher
10
11
/*关闭自增长*/
12
SET IDENTITY_INSERT teacher on
13
14
insert into teacher(id,name) values(2000,'guo')
15
16
/*打开自增长*/
17
SET IDENTITY_INSERT teacher off
18
19
insert into teacher(name) values('guo')
子增长的插入2
/*创建表*/3
create table teacher4
(5
id int identity(1,1) primary key not null,6
name varchar(20)7
)8

9
select * from teacher10

11
/*关闭自增长*/12
SET IDENTITY_INSERT teacher on 13

14
insert into teacher(id,name) values(2000,'guo')15

16
/*打开自增长*/17
SET IDENTITY_INSERT teacher off 18

19
insert into teacher(name) values('guo')

浙公网安备 33010602011771号