- 浏览: 2538970 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (676)
- linux运维 (157)
- php (65)
- mysql (78)
- nginx (27)
- apche (18)
- framework (6)
- windows (9)
- IDE工具 (23)
- struts2 (7)
- java (13)
- 移动互联网 (14)
- memcache redis (23)
- shell基础/命令/语法 (37)
- shell (50)
- puppet (4)
- C (11)
- python (9)
- 产品经理 (27)
- Sphinx (4)
- svn (12)
- 设计构建 (12)
- 项目管理 (44)
- SEO (1)
- 网站架构 (26)
- 审时度势 (42)
- 网络 (14)
- 激发事业[书&视频] (81)
- 其它 (12)
- 摄影 (8)
- android (21)
最新评论
-
zhongmin2012:
原文的书在哪里
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
renzhengzhi:
你好,请问个问题,从master同步数据到slave的时候,s ...
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
ibc789:
你好,看了你的文章,我想请教个问题, 我在用 redis的时候 ...
redis 的两种持久化方式及原理 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器
show errors;
SHOW TRIGGER;
DROP TRIGGER t1;
--------------------------创建触发器
:
语法:
1. CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name
2. FOR EACH ROW
3. BEGIN
4. trigger_stmt
5. END;
CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name
FOR EACH ROW
BEGIN
trigger_stmt
END;
大写的为关键字
trigger_name:触发器的名字,我常用的命名规则t_name_tableName_(b|a)(i|u|d),t:触发器标识,name:英文名,tableName:表名,b
(BEFORE):标识是触发事件之前,a(AFTER):标识触发事件之后,i(insert): 标识insert事件,u(update):标识update事件,d(delete):标识
delete事件;
trigger_time:触发时间(BEFORE或AFTER)
trigger_event:事件名(insert或update或delete)
tbl_name:表名(必须是永久性表)
trigger_stmt:执行语句(可以是复合语名),使用别名OLD和NEW,能够引用与触发程序相关的表中的列。
----------------------删除解发器
语法:
DROP TRIGGER [schema_name.]trigger_name;
注意:以上操作均需SUPER权限
示例:
1. DROP TRIGGER t_wiley_hotelComment_bu;
2. delimiter //
3. CREATE TRIGGER t_wiley_hotelComment_bu BEFORE UPDATE ON hotel_comment
4. FOR EACH ROW
5. BEGIN
6. IF OLD.ispass=0 && NEW.ispass=1 THEN
7. UPDATE hotel_info SET
sumcomment=sumcomment+1,sumconsume=sumconsume+NEW.consume,sumservice=sumservice+NEW.service,
sumroom=sumroom+NEW.room,sumentiron=sumentiron+NEW.entironment,total=total+(NEW.service+NEW.room+NEW.entironment) WHERE
hotel_id=NEW.hotel_id;
8. ELSEIF OLD.ispass=1 && NEW.ispass=0 THEN
9. UPDATE hotel_info SET sumcomment=sumcomment-1,sumconsume=sumconsume-NEW.consume,sumservice=sumservice-NEW.service,
sumroom=sumroom-NEW.room,sumentiron=sumentiron-NEW.entironment,total=total-(NEW.service+NEW.room+NEW.entironment) WHERE
hotel_id=NEW.hotel_id;
10. END IF;
11. END;//
12. delimiter ;
DROP TRIGGER t_wiley_hotelComment_bu;
delimiter //
CREATE TRIGGER t_wiley_hotelComment_bu BEFORE UPDATE ON hotel_comment
FOR EACH ROW
BEGIN
IF OLD.ispass=0 && NEW.ispass=1 THEN
UPDATE hotel_info SET sumcomment=sumcomment+1,sumconsume=sumconsume+NEW.consume,sumservice=sumservice+NEW.service,
sumroom=sumroom+NEW.room,sumentiron=sumentiron+NEW.entironment,total=total+(NEW.service+NEW.room+NEW.entironment) WHERE
hotel_id=NEW.hotel_id;
ELSEIF OLD.ispass=1 && NEW.ispass=0 THEN
UPDATE hotel_info SET sumcomment=sumcomment-1,sumconsume=sumconsume-NEW.consume,sumservice=sumservice-NEW.service,
sumroom=sumroom-NEW.room,sumentiron=sumentiron-NEW.entironment,total=total-(NEW.service+NEW.room+NEW.entironment) WHERE
hotel_id=NEW.hotel_id;
END IF;
END;//
delimiter ;
说明:delimiter 改变语句结束符
-----------------------------------------------实例
mysql> CREATE TABLE data (name VARCHAR(255));
Query OK, 0 rows affected (0.09 sec)
mysql> CREATE TABLE chars (count INT(10));
Query OK, 0 rows affected (0.07 sec)
mysql> INSERT INTO chars (count) VALUES (0);
Query OK, 1 row affected (0.00 sec)
mysql> CREATE TRIGGER t1 AFTER INSERT ON
data FOR EACH ROW UPDATE chars SET count
= count + CHAR_LENGTH(NEW.name);
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW TRIGGERSG;
*************************** 1. row ******************
?Trigger: t1
?Event: INSERT
?Table: data
Statement: UPDATE chars SET count = count + CHAR_LENGTH(NEW.name)
Timing: AFTER
?Created: NULL
ql_mode:
1 row in set (0.01 sec)
mysql> INSERT INTO data (name) VALUES ('Sue'), ('Jane');
Query OK, 2 rows affected (0.00 sec)
Records: 2?Duplicates: 0?Warnings: 0
mysql> SELECT * FROM chars;
+-------+
| count |
+-------+
| 7|
+-------+
1 row in set (0.00 sec)
注意:理想情况下,你还需要一个倒转触发器,每当一个记录从源表格中删除时,它从字符总数中减去记录的字符数。这很容易做到,你可以
把它当作练习来完成。提示:应用BEFORE DELETE ON子句是其中一种方法。
现在,我想建立一个审计记录来追踪对这个表格所做的改变。这个记录将反映表格的每项改变,并向用户说明由谁做出改变以及改变的时间。
我需要建立一个新表格来存储这一信息(表格名:audit),如下所示。
mysql> CREATE TABLE audit (id INT(7),
balance FLOAT, user VARCHAR(50)
NOT NULL, time TIMESTAMP NOT NULL);
Query OK, 0 rows affected (0.09 sec)
接下来,我将在accounts表格中定义一个触发器。
mysql> CREATE TRIGGER t1 AFTER UPDATEON accounts
FOR EACH ROW INSERT INTO audit (id, balance, user, time)
VALUES (OLD.id, NEW.balance, CURRENT_USER(), NOW());
Query OK, 0 rows affected (0.04 sec)
注释:accounts表格每经历一次UPDATE,触发器插入(INSERT)对应记录的id、新的余额、当前时间和登录audit表格的用户的名称。
----------------------------------PPC实例 MYSQL5触发器做数据同步
这几天公司要用触发器作数据同步。数据表有100多张,还不把人累死。所以写了个触发器的自动生成程序:
呵呵:把数据库名表名输入就OK了,生成的代码直接到mysql编译器里运行,触发器就上去了
[群号18255508] 大家一起来研究PHP一起工作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
-->
</style>
<script language="javascript">
function res(){
document.getElementById("tab2").value = "pre_"+document.getElementById("tab1").value;
}
</script>
</head>
<body>
<form action="#" method="post" name="form1" target="_blank" id="form1">
数据库名
<input name="dbTbaleName" type="text" id="dbTbaleName" value="dbname" />
<br>
驱动表
<input name="tab1" type="text" id="tab1" /> <br>
被触发的表
<input name="tab2" type="text" id="tab2" /><br>
<input type="submit" name="Submit" value="提交" /><br>
</form>
<?php
/**
* -------------------文档注释------------------------------------------
* 作者*达达*QQ 85089479*email qianshuei@163.com*
* 创建时间*2006-012-*
* 功能描述*数据同步触发器生成工具*
* 最后修改时间*2006-12-*
* -------------------------------------------------------------------
*/
$dbName = "localhost"; //主机名
$dbUserName = "root"; // 用户名
$dbpassword = "admin"; //密码
$dbTbaleName = $_POST['dbTbaleName']; //数据库名
$tab1 = $_POST['tab1']; //执行的表
$tab2 = $_POST['tab2']; //被触发的表
$conn = mysql_connect($dbName, $dbUserName, $dbpassword) or die("请检查你的主机名数据库用户名和密码");
mysql_select_db($dbTbaleName, $conn) or die("数据库还没有连接");
mysql_select_db("$dbTbaleName");
$result = mysql_query("select * from $tab1")//得到表查询的结果
or die("Query failed: " . mysql_error());
echo("<br>");
$i = 1;//这里是为了替换最后一个列名的,符号所以=1 <>0
echo "create trigger " . $tab1 . "_insert BEFORE INSERT on $tab1<br>";
echo "for each row BEGIN<br>";
echo "INSERT INTO $tab2 SET<br>";
while ($i < mysql_num_fields($result)){//列的数量的循环
$meta = mysql_fetch_field($result);//得到一个关于列的信息的对角
if (!$meta){
echo "No information available<br />\n";
}
//下面输出的是触发器程序列信息
echo "<pre>
`$meta->name`=NEW.$meta->name,
</pre>";
$i++;
}
$meta = mysql_fetch_field($result);
echo "<pre>
`$meta->name`=NEW.$meta->name;
</pre>";
mysql_free_result($result);
echo("END;");
// -----------------------------------------------------------------
$result = mysql_query("select * from $tab1")
or die("Query failed: " . mysql_error());
$i = 1;
if ($i < mysql_num_fields($result)){
$meta = mysql_fetch_field($result);
// -----------------------------------------------------------------
/**
* create trigger `tri_del` BEFORE DELETE on `aaa`
* for each row BEGIN
* DELETE FROM bbb WHERE id =OLD.id;
*/
echo("<br>");
echo "create trigger " . $tab1 . "_del BEFORE DELETE on $tab1<br>";
echo "for each row BEGIN<br>";
echo "DELETE FROM $tab2 WHERE $meta->name =OLD.$meta->name;<br>";
echo("END;");
}
// -----------------------------------------------------------------
echo("<br>");
/**
* create trigger `up_date` BEFORE UPDATE on `aaa`
* for each row BEGIN
* UPDATE bbb set a1 = new.a1 , a2=new.a2 where id = new.id;
* END;
*/
$result = mysql_query("select * from $tab1")
or die("Query failed: " . mysql_error());
/**
* get column metadata
*/
$i = 1;
echo "create trigger " . $tab1 . "_update BEFORE UPDATE on $tab1<br>";
echo "for each row BEGIN<br>";
echo "UPDATE $tab2 SET<br>";
while ($i < mysql_num_fields($result)){
$meta = mysql_fetch_field($result);
if (!$meta){
echo "No information available<br />\n";
}
echo "<pre>
`$meta->name`=NEW.$meta->name,
</pre>";
$i++;
}
$meta = mysql_fetch_field($result);
echo "<pre>
`$meta->name`=NEW.$meta->name
</pre>";
mysql_free_result($result);
// -----------------------------
$result = mysql_query("select * from $tab1")
or die("Query failed: " . mysql_error());
$i = 1;
if ($i < mysql_num_fields($result)){
$meta = mysql_fetch_field($result);
echo("where $meta->name = new.$meta->name;<br>");
echo("END;");
}
?>
=---------------------------------------实例
--
-- Triggers `timecard_spec`
--
DROP TRIGGER `hrms`.`timecard_spec_after_upd_tr`;
DELIMITER //
CREATE TRIGGER `hrms`.`timecard_spec_after_upd_tr` AFTER UPDATE ON `hrms`.`timecard_spec`
FOR EACH ROW BEGIN
set @emp_no=new.emp_no;
set @dept_id = new.dept_id;
set @full_name = new.full_name;
set @start_date = new.start_date;
set @total_day = new.total_day;
set @total_hour = new.total_hour;
set @total_minute = new.total_minute;
set @leave_type = new.leave_type;
set @t_status = new.status;
set @create_by = new.create_by;
set @update_by = new.update_by;
set @forget_times=new.forget_times;
if (@t_status=9 and @leave_type=21) then
set @cur_date=DATE_FORMAT(date_add(FROM_UNIXTIME(@start_date),interval -8 hour),'%Y-%m');
set @total_time =@total_day*480+@total_hour*60+@total_minute;
if (INSTR(@forget_times,'1,2')=1) then
set @forget_times=2;
else
set @forget_times=1;
end if;
if exists(select * from timecard_rpt where cur_date=@cur_date and emp_no =@emp_no) then
update timecard_rpt set forgot_timecard=forgot_timecard+@forget_times where cur_date=@cur_date and emp_no =@emp_no;
else
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,forgot_timecard,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@forget_times,@create_by,UNIX_TIMESTAMP(now()));
end if;
end if;
END
//
DELIMITER ;
DROP TRIGGER `hrms`.`employee_after_upd_tr`;
DELIMITER //
CREATE TRIGGER `hrms`.`employee_after_upd_tr` AFTER UPDATE ON `hrms`.`employee`
FOR EACH ROW BEGIN
set @my_leader = new.my_leader;
set @emp_no = new.emp_no;
set @create_by = new.create_by;
set @create_date= new.create_date;
if (exists(select emp_no from hr_relation where emp_no=@emp_no)) then
update hr_relation set leader_no = @my_leader,create_by=@create_by,create_date=@create_date where emp_no=@emp_no;
else
insert into hr_relation (emp_no,leader_no,create_date,create_by) values (@emp_no,@my_leader,@create_date,@create_by);
end if;
if (NEW.dept_id != OLD.dept_id) then
update timecard_rpt set dept_id = NEW.dept_id where emp_no = @emp_no;
end if;
END
//
DELIMITER ;
DROP TRIGGER `hrms`.`holiday_after_ins_tr`;
DELIMITER //
CREATE TRIGGER `hrms`.`holiday_after_ins_tr` AFTER UPDATE ON `hrms`.`holiday`
FOR EACH ROW BEGIN
set @emp_no=new.emp_no;
set @dept_id = new.dept_id;
set @full_name = new.full_name;
set @start_date = new.start_date;
set @total_day = new.total_day;
set @total_hour = new.total_hour;
set @total_minute = new.total_minute;
set @leave_type = new.leave_type;
set @t_status = new.status;
set @create_by = new.create_by;
set @update_by = new.update_by;
set @cur_date=DATE_FORMAT(date_add(FROM_UNIXTIME(@start_date),interval -8 hour),'%Y-%m');
set @total_time =@total_day*480+@total_hour*60+@total_minute;
if (@t_status=9) then
if exists(select * from timecard_rpt where cur_date=@cur_date and emp_no =@emp_no) then
if @leave_type=1 THEN
update timecard_rpt set leave_1=leave_1+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=2 THEN
update timecard_rpt set leave_2=leave_2+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=3 THEN
update timecard_rpt set leave_3=leave_3+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=4 THEN
update timecard_rpt set leave_4=leave_4+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=5 THEN
update timecard_rpt set leave_5=leave_5+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=6 THEN
update timecard_rpt set leave_6=leave_6+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=7 THEN
update timecard_rpt set leave_7=leave_7+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=8 THEN
update timecard_rpt set leave_8=leave_8+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=9 THEN
update timecard_rpt set leave_9=leave_9+@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=10 THEN
update timecard_rpt set leave_10=leave_10+@total_time where cur_date=@cur_date and emp_no =@emp_no;
end if;
else
if @leave_type=1 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_1,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=2 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_2,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=3 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_3,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=4 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_4,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=5 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_5,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=6 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_6,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=7 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_7,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=8 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_8,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=9 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_9,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
elseif @leave_type=10 THEN
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,leave_10,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@total_time,@create_by,UNIX_TIMESTAMP(now()));
end if;
end if;
elseif(@t_status=10) then
if @leave_type=1 THEN
update timecard_rpt set leave_1=leave_1-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=2 THEN
update timecard_rpt set leave_2=leave_2-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=3 THEN
update timecard_rpt set leave_3=leave_3-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=4 THEN
update timecard_rpt set leave_4=leave_4-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=5 THEN
update timecard_rpt set leave_5=leave_5-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=6 THEN
update timecard_rpt set leave_6=leave_6-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=7 THEN
update timecard_rpt set leave_7=leave_7-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=8 THEN
update timecard_rpt set leave_8=leave_8-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=9 THEN
update timecard_rpt set leave_9=leave_9-@total_time where cur_date=@cur_date and emp_no =@emp_no;
elseif @leave_type=10 THEN
update timecard_rpt set leave_10=leave_10-@total_time where cur_date=@cur_date and emp_no =@emp_no;
end if;
end if;
END
//
DELIMITER ;
DROP TRIGGER `hrms`.`timecard_spec_after_upd_tr`;
DELIMITER //
CREATE TRIGGER `hrms`.`timecard_spec_after_upd_tr` AFTER UPDATE ON `hrms`.`timecard_spec`
FOR EACH ROW BEGIN
set @emp_no=new.emp_no;
set @dept_id = new.dept_id;
set @full_name = new.full_name;
set @start_date = new.start_date;
set @total_day = new.total_day;
set @total_hour = new.total_hour;
set @total_minute = new.total_minute;
set @leave_type = new.leave_type;
set @t_status = new.status;
set @create_by = new.create_by;
set @update_by = new.update_by;
set @forget_times=new.forget_times;
if (@t_status=9 and @leave_type=21) then
set @cur_date=DATE_FORMAT(date_add(FROM_UNIXTIME(@start_date),interval -8 hour),'%Y-%m');
set @total_time =@total_day*480+@total_hour*60+@total_minute;
if (INSTR(@forget_times,'1,2')=1) then
set @forget_times=2;
else
set @forget_times=1;
end if;
if exists(select * from timecard_rpt where cur_date=@cur_date and emp_no =@emp_no) then
update timecard_rpt set forgot_timecard=forgot_timecard+@forget_times where cur_date=@cur_date and emp_no =@emp_no;
else
insert into timecard_rpt (dept_id,emp_no,full_name,cur_date,forgot_timecard,create_by,create_date)
values (@dept_id,@emp_no,@full_name,@cur_date,@forget_times,@create_by,UNIX_TIMESTAMP(now()));
end if;
end if;
END
//
DELIMITER ;
发表评论
-
mysql表修复
2015-04-07 10:16 102861.1命令myisamchk(必须停掉mysql服务,或者所操 ... -
Table_locks_immediate
2014-08-25 15:46 3062Table_locks_immediate表示立即释放表锁数 ... -
mysql分区
2014-02-21 10:38 1847mysql自5.1开始支持分区 ... -
InnoDB 引擎独立表空间 innodb_file_per_table
2013-02-25 11:14 1309http://deeplyloving.iteye.com ... -
mysql监测工具tuning-primer.sh
2013-01-21 17:57 2654【转】http://www.dbasky.net ... -
mysql主从日志的定期清理
2013-01-21 16:24 1153[转]http://wangwei007.blog.51 ... -
[转]Mysql报错:Result consisted of more than one row
2013-01-09 16:25 15862Error Code : 1172 Result consi ... -
根据bin log 分析管理员被莫名删除问题
2013-01-04 17:04 1161============== 根据bin log 分析管理 ... -
mysql中select * for update锁表的问题
2013-01-04 14:07 2508先前介绍过SELECT ... FOR UPDATE的用法 ... -
PDO报错:Cannot execute queries while other unbuffered queries are active.
2012-12-12 17:57 11925用 PDOStatement->execute() 执行 ... -
MySQL死锁导致无法查询
2012-12-11 14:51 2558客服反馈后台无法查询,原因大概知道,是因为MySQL的事务 ... -
mysql性能分析:mysql profiling 应用
2012-12-11 10:26 13441)先打开profiling ==> set pro ... -
mysql体系结构和查看当前的数据库请求
2012-12-07 15:00 2891mysql体系结构: 由 ... -
mysql_error:Error starting thread: Resource temporarily unavailable
2012-11-01 17:57 2109121031 18:53:17 InnoDB: Unable ... -
导出bin log时间段脚本datarecover.sh
2012-09-06 13:34 1242修改 _binlogdir='/data/mysql/m ... -
Mysql备份工具xtraback全量和增量测试
2012-08-17 14:58 3864【转载】http://blog.chinaunix.net/s ... -
数据库中的隔离级别和锁机制
2012-08-09 17:55 1585ANSI/ISO SQL92标准定义了 ... -
mysqldump和mysql命令
2012-08-03 13:44 1380========================= mys ... -
【汇总】mysql join
2012-07-18 11:35 1168标准SQL中CROSS JOIN交叉连接(笛卡尔积)和内连接I ... -
mysql cursor游标的使用,实例
2012-07-17 23:09 1809mysql被oracle收购后,从mysql-5.5开始, ...
相关推荐
本文实例讲述了mysql触发器之创建多个触发器操作。分享给大家供大家参考,具体如下: 这次记录的内容mysql 版本必须得是5.7.2+的哈,之前的会不好使的。废话不多说,咱们开始正文哈。 在mysql 5.7.2+版本之前,我们...
MySQL触发器是数据库管理系统提供的一种机制,用于在特定的数据操作(如INSERT、UPDATE、DELETE)发生之前或之后自动执行预定义的SQL语句。这些触发器可以用来实现复杂的业务规则,确保数据的一致性和完整性,或者...
MySQL触发器是数据库管理系统中的一种重要机制,它允许在特定的数据库操作(如INSERT、UPDATE、DELETE)发生前后自动执行一段预定义的SQL代码。触发器的引入是为了满足更复杂的数据完整性需求,提供数据验证、业务...
文件“MySQL存储过程.pdf”和“OReilly.MySQL.Stored.Procedure.Programming.rar”可能会提供关于如何创建、调用和管理MySQL存储过程的详细指南,而“MySQL触发器.rar”则可能包含触发器的创建、使用和优化方面的...
### MySQL触发器详解 #### 引言 MySQL触发器,作为MySQL 5.0版本引入的一项重要特性,为数据库管理提供了更为精细的控制能力。触发器允许在特定的数据库操作(如INSERT、UPDATE、DELETE)发生时自动执行SQL语句,...
MYSQL触发器,可以使用它用来进行监控,例如商品价格变化,下单后商品库存减少等实用性操作!
在深入探讨MySQL触发器的使用之前,我们先来理解一下什么是触发器以及它在数据库管理中的作用。触发器是数据库中一种特殊的存储过程,当特定的事件(如INSERT、UPDATE或DELETE操作)在指定的表上发生时自动执行。...
### MySQL触发器教程知识点详解 #### 一、MySQL触发器简介 MySQL触发器是一种存储在数据库中的特殊类型的存储过程,当特定的事件(如插入、更新或删除数据)发生时自动执行。它们允许用户定义一系列复杂的规则和...
### MySQL触发器知识点详解 #### 引言 MySQL触发器是一种服务器端的程序,它可以响应特定的数据库事件(如插入、更新或删除记录)而自动执行。触发器自MySQL 5.0版本起被引入,这标志着MySQL在功能性上的一大进步,...
MySQL触发器是数据库管理系统中的一个重要概念,主要用于在特定的数据操作(如INSERT、UPDATE或DELETE)发生时自动执行预定义的SQL语句。这些语句可以是复杂的业务逻辑,用于实现数据验证、同步或其他自动化任务。...
本文实例讲述了mysql触发器之创建使用触发器。分享给大家供大家参考,具体如下: 我们可以可以使用CREATE TRIGGER语句创建一个新的触发器,来看下具体的语法: CREATE TRIGGER trigger_name trigger_time trigger_...
### MySQL触发器、存储过程、自定义函数、视图示例 #### 一、MySQL触发器 触发器是一种特殊类型的存储过程,它被设计为在特定事件(如INSERT、UPDATE或DELETE操作)发生时自动执行。触发器可以用来强制业务规则、...
MySQL触发器是数据库管理系统中的一个重要特性,它允许在特定的数据库操作(如INSERT、UPDATE或DELETE)发生之前或之后执行自定义的SQL代码。这些自动执行的代码块可以用来实现复杂的业务逻辑,确保数据的一致性和...
MySQL触发器是数据库管理系统中的一个重要特性,它允许在特定的数据操作(如INSERT、UPDATE或DELETE)发生时自动执行预定义的SQL语句。这为数据库的业务规则提供了强大的支持,可以确保数据的一致性和完整性。以下是...
【MySQL触发器详解】 MySQL触发器是数据库管理系统中的一种重要特性,它允许用户在特定的数据库操作(如INSERT、UPDATE或DELETE)发生之前或之后自动执行预定义的SQL语句。这种特性使得数据库能实现更复杂的业务...
在MySQL数据库中,触发器是一种非常强大的工具,可以在特定的数据操作(如INSERT, UPDATE, DELETE)发生时自动执行预定义的SQL语句。在PHP项目中,我们可以利用触发器来实现信息的备份、恢复和清空功能,以提高数据...