php 小试 mysql-zmq-plugin 和 pthreads
原文: http://my.oschina.net/neochen/blog/294354
https://github.com/netkiller/mysql-zmq-plugin
有2张表:
表1:device, 里面有最主要的2个字段(id, device_type, .....),表明了"设备类型"与"ID";
表2:alarm_information,记录了每种设备的告警信息,其中有2个主要字段(id, device_type, ....);
要求:当 device中的某项被删除的时候,alarm_information中该设备所有的告警信息全部被删除。
在device中创建触发器:
///////////////////////////////////////////////////////////////////////////////////////////////
create trigger update_alarm_information before delete on device
for each row
begin
set @id=OLD.id; //保存被删除设备的“id”
set @dtype=OLD.device_type; //保存被删除记录的“device_type”
delete from alarm_information where id=@id and device_type = @dtype;
end;
///////////////////////////////////////////////////////////////////////////////////////////////
如果用Navicat for Mysql创建触发器就更加方便了
- 首先选择表device,点击右键,在弹出菜单中选择“设计表”
- 选择“触发器”
- 3. 在定义框中写入:
begin
set @id=OLD.id; //保存被删除设备的“id”set @dtype=OLD.device_type; //保存被删除记录的“device_type”
delete from alarm_information where id=@id and device_type = @dtype;
end;4. 完成
示例一
delimiter //
create trigger InsertUser
before insert on user
for each row
Begin
insert into user_group(uid,gid) values(new.uid,'group4444444444');
end;//
delimiter ; 示例二
delimiter //
create trigger InsertUser
before insert on user
for each row
Begin
IF new.Type=2 then
insert into user_group(uid,gid) values(new.uid,'group4444444444');
else
insert into user_group(uid,gid) values(new.uid,'group55555555555')
END IF;
end;//
delimiter ; 示例三:
delimiter //
create trigger InsertUser
before insert on user
for each row
Begin
IF new.type=1 then
insert into user_group(uid,gid) values(new.uid,'578d3369633b47bd9c1fe8bf905cbfb1');
END IF;
IF new.type=2 then
insert into user_group(uid,gid) values(new.uid,'387bcd57fc5a4c3c9de83ee210fef661');
END IF;
end;//
delimiter ;
php 小试 mysql-zmq-plugin 和 pthreads的更多相关文章
- 从源码角度看MySQL memcached plugin——0.大纲
本系列文章介绍MySQL memcached plugin插件.剖析已经完成.先把链接弄好,内容会陆续补上. 大纲如下: 系统结构和引擎初始化(已完成) 线程模型和连接的状态机 containers表 ...
- 使用MySQL审计Plugin
本文来源:http://blog.chinaunix.net/uid-20785090-id-5018977.html 越来越多的企业把应用往mysql上迁移,这时候对数据库的审计又成了一件紧急的事情 ...
- 远程连接MySQL错误“plugin caching_sha2_password could not be loaded”的解决办法
远程连接MySQL错误"plugin caching_sha2_password could not be loaded"的解决办法 问题描述: 今天在阿里云租了一个服务器,当我用 ...
- mysql mybatis-generator plugin 有page实体类的分页
page实体类 package cn.zsmy.tmp; import java.io.Serializable; /** * 分页对象. * */public final class Page im ...
- mysql mybatis-generator plugin 分页
generator.xml配置如下: plugin必须紧跟context,否则会报错 <?xml version="1.0" encoding="UTF-8&quo ...
- Mysql错误处理: /usr/bin/mysqld_safe: line xxx: xxxx Killed ... (mysql自动停止 Plugin FEDERATED is disabled 的完美解决方法)
哈哈哈,问题总算解决,内心抑不住的开心 centos mysql 问题:Plugin 'FEDERATED' is disabled. /usr/sbin/mysqld: Table 'mysql.p ...
- 连接MySQL错误“plugin caching_sha2_password could not be loaded”的解决办法
MySQL新版默认使用caching_sha2_password作为身份验证插件,而旧版是使用mysql_native_password.当连接MySQL时报错“plugin caching_sha2 ...
- 从源码角度看MySQL memcached plugin——1. 系统结构和引擎初始化
本章尝试回答两个问题: 一.memcached plugin与MySQL的关系: 二.MySQL系统如何启动memcached plugin. 1. memcached plugin与MySQL的关系 ...
- MySQL Authentication plugin 'caching_sha2_password' cannot be loaded
很多用户在使用Navicat Premium 12连接MySQL数据库时会出现Authentication plugin 'caching_sha2_password' cannot be loade ...
- mysql Authentication plugin 'caching_sha2_password' is not supported问题处理
使用mysql8.0版本,登录失败,提示 Authentication plugin 'caching_sha2_password' is not supported. 原因是在MySQL 8.0以后 ...
随机推荐
- Spring XML配置文件示例(一)——<Servlet name>-servlet.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- 解决phpcms V9 推荐位无法排序
/phpcms/modules/content/content.php 454行 /** * 排序 */public function listorder() { if(isset($_GET['do ...
- 深入分析JavaWeb 技术内幕
1,通过浏览器请求一个资源,会发生以下几种过程 1) http的解析过程,包括对于http请求头和响应头中指令(控制用户浏览器的渲染行为和 服务器的执行逻辑)的解析 2)DNS的解析过程(根据域名获取 ...
- unity3D与网页的交互---做项目的一点总结
(来自博客园) 由于项目需要,要求用unity来展示三维场景,并在三维中能够方便的查询数据库等.一开始尝试在unity中直接连接数据库,当时连的xml,然而每次发布成网页后都会出现路径找不到等问题,所 ...
- HTTP访问的两种方式(HttpClient+HttpURLConnection)整合汇总对比(转)
在Android上http 操作类有两种,分别是HttpClient和HttpURLConnection,其中两个类的详细介绍可以问度娘. HttpClient: HttpClient是Apache ...
- c文件操作 (转)
文件文件的基本概念 所谓“文件”是指一组相关数据的有序集合. 这个数据集有一个名称,叫做文件名. 实际上在前面的各章中我们已经多次使用了文件,例如源程序文件.目标文件.可执行文件.库文件 (头文件)等 ...
- ListView中每个item条目在被单击选中时能够高亮显示
在布局文件中设定: android:listSelector="@android:color/holo_red_light" 在代码中实现 listView.setSelector ...
- Codeforces Round #130 (Div. 2) C. Police Station
题目链接:http://codeforces.com/contest/208/problem/C 思路:题目要求的是经过1~N的最短路上的某个点的路径数 / 最短路的条数的最大值.一开始我是用spf ...
- 如何通过java代码对kylin进行cube build
通常是用于增量 代码如下: package com.dlht.kylinDemo; import java.io.BufferedReader; import java.io.FileNotFound ...
- adb server is out of date. killing解决方法
adb server is out of date. killing完美解决 今天,久未出现的著名的“adb server is out of date. killing”又发生了,在此,将解决方 ...