SQL SERVER 基本语句操作

以下是SQL语句的基本操作

1、创建数据库表

/*创建学生表*/
create table tb_student(
	Sno nvarchar(50) not null,
	Sname nvarchar(30) not null,
	Ssex nvarchar(10),
	Sage int,
	Sclass nvarchar(30),
	constraint pk_sno primary key clustered(Sno)
)

2、插入数据

/*插入学生*/
insert into tb_student values ('001','张静','女',20,'一班');
insert into tb_student values ('002','王伟','男',19,'二班');
insert into tb_student values ('003','张三','男',18,'二班');

3、更新数据

/*更新学号为001班级为二班*/
update tb_student set Sclass = '二班' where Sno = '001'

4、删除数据

/*删除学号为003的学生*/
delete from tb_student where Sno = '003'

5、查询数据

/*查询学生表所有数据*/
select * from tb_student
发布了21 篇原创文章 · 获赞 0 · 访问量 614

猜你喜欢

转载自blog.csdn.net/Stodger0216/article/details/102840744