随笔分类 - SQL Server
SQL的一些简单操作
摘要:1 --创建数据库 2 Create DataBase School 3 go 4 5 --选中一个数据库 6 use School 7 go 8 9 --使用系统存储过程sp_helpdb查看数据库信息 10 11 sp_helpdb --查询所有数据库信息 12 go 13 14 sp_helpdb 'SQLSchool' --查询指定数据库信息 15 go 16 ...
阅读全文
摘要:1 create database yourschool 2 go 3 4 use yourschool 5 go 6 7 8 --创建表 9 10 create table teacher 11 ( 12 tId int primary key identity(1,1), --identity设立自增长,从1开始每增加一条记录,主键值...
阅读全文
摘要:1 use sqlschool 2 go 3 --内连接(普通连接查询) 4 5 --Sql92 6 7 drop table sc 8 go 9 create table sc 10 ( 11 stuId char(8), 12 cName varchar(20), 13 cGrade numeric(3,1) check...
阅读全文
摘要:1 --使用like进行模糊查询 2 3 --查询所有姓王的同学的信息 4 5 select * from student where stuName like '王%' 6 7 --'%'号与任意个字符相匹配其实就是0到n个 8 9 --查询所有赵姓同学的信息并且其名字是两个字 10 11 select * from stude...
阅读全文
摘要:1 select * from student 2 3 4 --查询平均成绩大于70分的系 5 6 select stuDept from student 7 8 9 10 11 select stuDept from student 12 group by stuDept 13 having avg(stuAvgrade) > 70 14 -- 15 sele...
阅读全文
摘要:分组必统计,分组查询其实是排序 1 --使用in查询信息工程系和电子商务系的学生 2 3 --查询信息工程系和电子商务系的学生 4 5 select * from student where stuDept='信息工程系' or stuDept='电子商务系' 6 7 select * from student where stuDept in('电子商务系'...
阅读全文
摘要:1 use 2 SqlSchool 3 go 4 5 --选择所有列 6 select * from student 7 8 --查询学生的姓名,性别,专业和系,起友好列名 9 select stuName 学生姓名, stuSex as 性别, 10 stuSpeciality as 专业, 11 stuDept as 系 12...
阅读全文
摘要:select * from table where someOne = ' ' --按照条件查找 delete table where key = keyValue --按照主键删除 update table set someOne = 'someOne' where key = keyValue
阅读全文

浙公网安备 33010602011771号