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

时间:2025-07-01

完整的数据库代码,实现小型数据库的所有功能,包括登录判断,注入式攻击,存储过程。。。。。。。。。



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

…… 此处隐藏:777字,全部文档内容请下载后查看。喜欢就下载吧 ……
sql完整数据库操作、存储过程、登录判断,增删改.doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219