手机版

sql完整数据库操作、存储过程、登录判断,增删改

发布时间: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

sql完整数据库操作、存储过程、登录判断,增删改.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)