当前位置:网站首页>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 .
边栏推荐
- Common validation comments
- Leetcode sword finger offer brush questions - day 20
- 通信设备商,到底有哪些岗位?
- Live online system source code, using valueanimator to achieve view zoom in and out animation effect
- 图解GPT3的工作原理
- Value sequence (subsequence contribution problem)
- [SUCTF 2019]Game
- Asemi rectifier bridge rs210 parameters, rs210 specifications, rs210 package
- 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
- Kbu1510-asemi power supply special 15A rectifier bridge kbu1510
猜你喜欢
随机推荐
Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
1141_ SiCp learning notes_ Functions abstracted as black boxes
buuctf misc USB
Gslx680 touch screen driver source code analysis (gslx680. C)
The metauniverse of the platofarm farm continues to expand, with Dao governance as the core
You Li takes you to talk about C language 6 (common keywords)
A bit of knowledge - about Apple Certified MFI
Weibo publishing cases
[webrtc] M98 screen and window acquisition
Leanote private cloud note building
为什么要了解现货黄金走势?
KBU1510-ASEMI电源专用15A整流桥KBU1510
【webrtc】m98 screen和window采集
【obs】win-capture需要winrt
图解GPT3的工作原理
leanote私有云笔记搭建
2022-07-06:以下go语言代码是否会panic?A:会;B:不会。 package main import “C“ func main() { var ch chan struct
[Stanford Jiwang cs144 project] lab3: tcpsender
Problem solving: unable to connect to redis
gslx680触摸屏驱动源码码分析(gslX680.c)