没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/89019899/bg1.jpg)
事件•
创建一个事件,它每个月启动一次,用于每个月向表tg_emp 中插入一条数据。开始于下一个月并且在2024年的12月31日结束
•
触发器•
create tri
gg
er tr
_
be
_
insert befor
e
insert on tb
_
1 for each row set @str=new.id
;
插入前:str=null 插入后:str=0
create trigger tr_af_insert after insert on tb_1 for each row set @str=new.id
;
插入前:str=null 插入后:str=3
create trigger tr_af_delete after delete on tb_1 for each row set @str3=old.id
;
删除前:str3=null 删除后:str3=3
create trigger tr_update afte
r
update on myclass for each row set @tr=ne
w
.name
;
更新前:tr=null 更新后:tr=jiezhou
create trigger tr_update afte
r
update on myclass for each row set @tr=old.name
;
更新前:tr=jiezhou(在执行前面的操作下) 更新后:tr=Bob
create tri
gg
er tr
_
be before update on m
y
class for each row set @trr=ne
w
.name
;
练习题
2024年3月6日
9:59
![](https://csdnimg.cn/release/download_crawler_static/89019899/bg2.jpg)
执行语句:update myclass set name='BB' where name='SS';
更新前:trr=null
更新后:trr=BB
create trigger tr_be1 before update on myclass for each row set @trrr=old.name
;
执行语句:update myclass set name='ALE' where name='alex';
更新前:trrr=null
更新后:trrr=alex
存储过程•
delimiter //
create procedure age(in age_1 int,out age_2 int)
begin
declare age_3 int;
set age_3=age_1;
set age_2=age_3;
end //
set @user=1
;
call age(3,@user)
;
执行完上述语句后: user = 3
将查询结果赋值给变量时,可以使用into关键字,既可以在select子句末尾写into关键字,也可以在值后面写into语句。
delimiter //
create procedure name(in age_1 int,out age_2 varchar(255),out name_1 varchar(255)
)
begin
select age,name from myclass where name='BB' into age_2, name_1;
end //
set @user=1;
set @user=2;
call name(3,@user1,@user2);
执行完上述语句后:user1=BB的年龄,user2=BB
二级练习题:
4
alter table tb_student add ssex char(1) default 'M';
¾
update tb_student set smajor='计算机' where sno=100;¾
create view v_avg(cname,caverage) as select cname,avg(grade) as caverage from tb_score group by cname;
¾
alter table tb_student add unique index idx_stu(sno); 或者 createuniqueindexidx_stuontb_student(sno);¾
create user 'newuser'@'localhost'; grant select on tb_student to 'newuser'@'localhost' with grant option;
¾
![](https://csdnimg.cn/release/download_crawler_static/89019899/bg3.jpg)
第一题: functionmax(grade)tmp
DELIMITER $$
CREATE ________ fn_cmax(cn CHAR(20)
)
RETURNS in
t
DETERMINISTIC
BEGIN
DECLARE tmp INT;
SELECT ________ INTO tmp
FROM tb_score
WHERE cname=cn;
RETURN ______;
END $$
DELIMITER ;
¾
第二题: eventeverytb_student¾
DELIMITER$$
CREATE______ev_bakON SCHEDULE_______1DAY
DO
BEGIN
SELECT*FROM________INTOOUTFILE'bakfile.txt'FIELDSTERMINATEDBY',';
END
5
create unique index idx_dept on tb_dept(deptname desc); 或者 altertabletb_deptadduniqueindexidx_dept(deptname
desc);
¾
insert into tb_dept(deptno,deptname) values ('D4','营销部');¾
select2014-birthas'年龄',nameas'姓名'fromtb_emp;¾
create view v_dept(部门负责人姓名,姓名,学历,工资) as select manager,name,education,salary from tb_dept,tb_emp where
deptname='市场部' and tb_dept.deptno=tb_emp.deptno;
¾
create user 'stud'@'localhost' ; grant select on tb_emp to 'stud'@'localhost' with grant option;
¾
第一题:returns workage>=30 fn_yggl¾
剩余18页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/737257ef517d40c7ad876978b37686b3_m0_46366547.jpg!1)
Vaeeeeeee
- 粉丝: 245
- 资源: 4
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 城市鎏金风素材PPT.pptx
- 305建筑结构水电欧式6套(14.5x20.2)\施工图\C型施工图\水1TJ-卫生间大样031020.dwg
- 305建筑结构水电欧式6套(14.5x20.2)\施工图\C型施工图\水1-C型平面031014.dwg
- 305建筑结构水电欧式6套(14.5x20.2)\施工图\C型施工图\水1-C型平面(改).dwg
- 建筑结构水电欧式6套(14.5x20.2)\施工图\C型施工图\煤气-2dy.dwg
- 基于Python语言和pygame库开发了一款名为“接金币”的休闲游戏
- MATLAB用户指南或参考手册
- H.264视频流解析工具
- 305建筑结构水电欧式6套(14.5x20.2)\施工设计说明-02.dwg
- 高代大作业-矩阵在图像几何变换中的应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)