当前位置:网站首页>Linux server development, MySQL stored procedures, functions and triggers
Linux server development, MySQL stored procedures, functions and triggers
2022-07-07 07:50:00 【Tuen Mun pheasant calls me chicken】
Recommend a free open course of zero sound College , Personally, I think the teacher spoke well , Share with you :Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK, Streaming media ,CDN,P2P,K8S,Docker,TCP/IP, coroutines ,DPDK Etc , Learn now
SQL Statements need to be compiled before execution , Stored procedures are a group of procedures designed to accomplish specific functions SQL Statements set , It is compiled and stored in a database .
delimiter // -- The ending character is temporarily changed to //
CREATE PROCEDURE pro_test(IN p int ,)
BEGIN
SELECT 1;
SELECT 2;
END
//
delimiter ;
SET @p2_in=1;
CALL pro_test(p2_in);
SELECT @p2_in;
- IN For input parameters
- OUT Is the output parameter
1. The cursor
CREATE PROCEDURE proc_normal(IN in_age int ,out out_taotal int)
BEGIN
DECLARE p_id int;
DECLARE p_name varchar(20);
DECLARE p_total int;
DECLARE done int default 0;
SET out_taotal =0;
CREATE cur_teacher CURSOR FOR SELECT teacher.id,teacher.name FROM teacher;
DECALRE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur_teacher;
cur_loop :LOOP
FECTH cur_teacher INTO p_id,p_name;
IF done = 1 THEN
LEAVE cur_loop;
END IF
SELECT p_id,p_name
SET p_total=p_total+p_id;
END LOOP
CLOSE cur_teacher;
SET out_taotal =p_total;
END
Cyclic replacement WHILE
WHILE done != 1
END WHILE
Cyclic replacement REPEATE
REPEATE
UNTIL done =1
END REPEATE
2. function
- SELECT abs(-2);
- SELECT round(4,4);
- SELECT concat(“000”,“123123”);
- SELECT month(“2022-01-28”);
- SELECT format(111,5);
- SHOW FUNCTION STATUS;
3. trigger
Trigger four elements : Monitoring sites , Monitoring events , The trigger condition , Trigger time .
CREATE TRIGER tri_test BEFORE | AFTER INSERT ON work EACH ROW
BEGIN
INSERT INTO ‘works’ value (NULL,NEW.id,‘ Changsha ’);
END
- stay INSERT Type trigger ,NEW Used to indicate that you are going to (BEFORE) Or already (AFTER) New data inserted .
- stay DELETE Type trigger ,OLD Used to represent the original data that will be or has been deleted .
- stay UPDATE Type trigger ,OLD Used to represent data that will be or has been modified ,NEW Used to indicate that the data to be changed into new data .
边栏推荐
- Live online system source code, using valueanimator to achieve view zoom in and out animation effect
- Installing postgresql11 database under centos7
- PHP exports millions of data
- 解决could not find or load the Qt platform plugin “xcb“in ““.
- buuctf misc USB
- idea添加类注释模板和方法模板
- Tongda injection 0day
- JSON introduction and JS parsing JSON
- Solve could not find or load the QT platform plugin "xcb" in "
- [unity] several ideas about circular motion of objects
猜你喜欢
1141_ SiCp learning notes_ Functions abstracted as black boxes
[UTCTF2020]file header
Jenkins remote build project timeout problem
[CV] Wu Enda machine learning course notes | Chapter 8
Make a bat file for cleaning system garbage
2022-07-06: will the following go language codes be panic? A: Meeting; B: No. package main import “C“ func main() { var ch chan struct
通信设备商,到底有哪些岗位?
【Unity】物体做圆周运动的几个思路
Common validation comments
[Stanford Jiwang cs144 project] lab4: tcpconnection
随机推荐
[unity] several ideas about circular motion of objects
Is the test cycle compressed? Teach you 9 ways to deal with it
Idea add class annotation template and method template
@component(““)
[advanced digital IC Verification] command query method and common command interpretation of VCs tool
Hands on deep learning (IV) -- convolutional neural network CNN
Iterable、Collection、List 的常见方法签名以及含义
[OBS] win capture requires winrt
php导出百万数据
大视频文件的缓冲播放原理以及实现
Asemi rectifier bridge rs210 parameters, rs210 specifications, rs210 package
leetcode:105. Constructing binary trees from preorder and inorder traversal sequences
Leetcode 43 String multiplication (2022.02.12)
Explore Cassandra's decentralized distributed architecture
Ansible
pytest+allure+jenkins環境--填坑完畢
pytest+allure+jenkins环境--填坑完毕
Solution: could not find kf5 (missing: coreaddons dbusaddons doctools xmlgui)
nacos
The metauniverse of the platofarm farm continues to expand, with Dao governance as the core