sql完整数据库操作、存储过程、登录判断,增删改
发布时间:2021-06-05
发布时间:2021-06-05
完整的数据库代码,实现小型数据库的所有功能,包括登录判断,注入式攻击,存储过程。。。。。。。。。
create database AA
go
use AA
go
create table Student
(
sid int primary key,
sname nvarchar(20),
sex nvarchar(20),
birthday datetime,
class nvarchar(10),
pwd nvarchar(10)
)
go
create table Course
(
cid int identity(1,1) primary key,
cname nvarchar(20)
)
go
create table Score
(
sid int,
cid int,
score int,
primary key(sid,cid)
)
go
insert into Course values('C#')
insert into Course values('English')
insert into Student values(1001,'张三','男', '1990-1-12','一班','123')
insert into Student values(1002,'李四','女', '1990-4-20','一班','456')
insert into Student values(1003,'王五','男', '1991-10-11','二班','789')
insert into Student values(1004,'赵六','男', '1992-8-5','二班','101')
insert into Student values(1005,'天齐','男', '1992-5-5','三班','120')
insert into Score values(1001,1,65)
insert into Score values(1001,2,60)
insert into Score values(1002,1,50)
insert into Score values(1002,2,40)
insert into Score values(1003,1,75)
insert into Score values(1003,2,60)
insert into Score values(1004,1,72)
insert into Score values(1004,2,45)
select * from student
select sname from student
select sid,sname from student
select * from student order by sid desc --desc 降序 asc 升序
select * from student order by sex,class asc
select * from student order by birthday desc
select * from student where sid=1001
select * from student where sex='男' and birthday>'1991-1-1'
select * from student where birthday between '1990-1-1' and '1991-1-1'
select * from student where sname like '%五%' --%%是通配符
select distinct(class) from student --去除重复项
select count(sid) from student
select count(sid) from student where sid=1001 and pwd='123'
select count(sid),class from student group by class
select count(sid),sex from student group by sex
select count(sid),sex,class from student group by sex,class
select count(sid),class from student where sex='男' group by class
select sum(score) from score
select avg(score) from score where sid=1001
select max(score),cid from score group by cid
select avg(score),cid from score group by cid having avg(score)>60
select avg(score),sid,cid from score group by sid,cid having avg(score)<60
select avg(score),sid from score group by sid having avg(score)>59
select * from score where score = (select max(score) from score)
select * from student where birthday = (select min(birthday) from student)
select * from student
select * from course
select * from score
select count(sid) as Y_N from student where sid=1001 and pwd='123'
--select avg(score) as avg from score where sid=1001
--select count(sid),class from student group by class
--select count(sid),sex from student group by sex
--select co
unt(sid),class,sex from student group by class,sex
--select count(sid),class from student where sex='男' group by class
--内连接
select stude
上一篇:篮球《三步上篮》教案
下一篇:中学英语新课程标准词汇表