-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest.sql
40 lines (31 loc) · 860 Bytes
/
test.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
DROP DATABASE IF EXISTS mysql_note;
CREATE DATABASE mysql_note;
USE mysql_note;
CREATE TABLE post (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(64) NOT NULL,
content TEXT DEFAULT NULL,
image VARCHAR(260) DEFAULT NULL
);
DROP FUNCTION IF EXISTS MySQLNotification;
CREATE FUNCTION MySQLNotification RETURNS INTEGER SONAME 'mysql-notification.so';
DELIMITER @@
DROP TRIGGER IF EXISTS trigger1;
CREATE TRIGGER trigger1 AFTER INSERT ON post
FOR EACH ROW
BEGIN
SELECT MySQLNotification(NEW.id, 2) INTO @x;
END@@
DROP TRIGGER IF EXISTS trigger2;
CREATE TRIGGER trigger2 AFTER UPDATE ON post
FOR EACH ROW
BEGIN
SELECT MySQLNotification(NEW.id, 3) INTO @x;
END@@
DROP TRIGGER IF EXISTS trigger3;
CREATE TRIGGER trigger3 AFTER DELETE ON post
FOR EACH ROW
BEGIN
SELECT MySQLNotification(OLD.id, 4) INTO @x;
END@@
DELIMITER ;