热线电话:13121318867

登录
2019-03-14 阅读量: 729
sql server中新建一个表

在helloworld数据库中新建一个student表

use helloworld
create table student(
id bigint PRIMARY KEY identity(1,1), --id为bigint类型数据,identity(标识种子,递增量)
name nvarchar(10)
age int,
gender varchar(1) not null --如果数据允许为空可以不写not null,默认的是null
)

一次添加多个数据

select * from student
insert student(name, age, gender)
values('xiaoming','18','1'),('xiahua','28','1'),('xiali','48','1'),('xiahei','68','0')

删除表中id>3的学生的数据

delete student where id>3
select * from student

把id为4的删除了,再添加一个数据,id为5不是4, 因为id这个变量用了identity(1,1)语句

insert into student values('xiaoqiao','88','1')

为所有行的指定列进行修改, id=1的性别改为"0"

update student set gender='0'
where id=1

26.6447
3
关注作者
收藏
评论(0)

发表评论

暂无数据