SQL IDENTITY

来源:互联网 发布:ip端口打开失败 编辑:程序博客网 时间:2024/06/05 10:33
--Create Students table.Create table Students (id int Identity primary key,student varchar(40))go--Inserting values into products table.Insert into students(student) values ('lizuwu')Insert into students(student) values ('wuhaiyan')Insert into students(student) values ('wudi')go--Create a gap in the identity values.\delete students where student='wudi'GOselect * from studentsGO--Attempt to insert an explicit ID value of 3;--shoud return a warning.insert into students(id,student) values(3,'xiaowudi')GO--set Identity_Insert to On.set identity_insert students ongo--attempt to insert an explicit id values of 3insert into sutdents(student) values('xiaowudi');set @ID=@@identity;goselect * from studentsgo--drop students tableDrop table studentsgo

原创粉丝点击