The following two examples are from:Http://www.cnblogs.com/nicholas_f/archive/2009/09/22/1572050.htmlThe actual measurement is valid, but the original post delimiter is not correct, so modify it slightly.Where old means tab2 (passive trigger), new represents TAB1 (active, external application executes INSERT statement in this table)Example 1:Create two tables to add one record in one table, and another to add a record:DROP TABLE IF EXISTS tab1;CREATE
Tags: mysql val let div drop delete font update name DROP TRIGGER IF EXISTST_a_b;/*Delete Trigger*/
CREATE TRIGGERT_a_b/*Create a trigger T_a_b*/ AfterINSERT onA/*identification trigger time, value is before or after;*/
/*Thus, there are 6
The event scheduler can sometimes also be called a temporary trigger (temporal triggers),Because the event scheduler performs certain tasks based on a specific time period trigger, the trigger (Triggers) is triggered based on events generated by a table, and the difference is here.Before you can use this feature, you must ensure that Event_scheduler is turned on
MySQL synchronizes two tables with a triggerCurrently, the test is successful locally.Suppose that the local two databases A and b,a have table table1 (ID, Val) under B with table table2 (ID, Val)Assume that you want data to be updated in the Table1, and the data in Table2 is updated synchronously.Code:DELIMITER $$CREATE/*[definer = {User | Current_User}]*/TRIGGER ' a '. '
Label:Run under the Mysql.exe.If yes, it may be necessary to add a definition DELIMITER//It means to tell MySQL that the statement ended after encountering//symbols.Otherwise, if MySQL encounters a semicolon, it thinks the statement is over and the trigger code is not finished.Mysql> DELIMITER//mysql> CREATE
MySQL stored procedures and function stored proceduresDownloadDemoMysql> delimiter// --here//for modifying the default delimiter;mysql> CREATE PROCEDURE simpleproc (out param1 INT) beginThis calls the trial callMysql> call Simpleproc (@a); Mysql> Select @a;Function DemoParameter does not have input/output parametersmysql> CREATE FUNCTION Hello (S CHAR ())
Label:#表 ( jc_shop_product ) has a status value-whether the shelves (On_sale) to shelves (0) into the shelf (1) and set the shelf time (on_sale_time) Drop trigger if exists update_on_sale_time_of_product;
Delimiter//
CREATE TRIGGER update_on_sale_time_of_product before update on jc_shop_product for each
ROW
BEGIN
IF old.on_sale=0 new.on_sale=1 then
SET new.on_sale_time=now ();
END IF;
END;
delimiter; A
time, but for us is only a blink of an eye, as long as the separation of two execution time is enough. A little bit of personal experience, hope to help everyone. Individual environment yo often check show variables like '%event_scheduler% '; make sure this database permission is already open OK To open the Event_scheduler SQL command:SET GLOBAL event_scheduler = on;SET @ @global. Event_scheduler = on;SET GLOBAL event_scheduler = 1;SET @ @global. Event_scheduler = 1;Instead, close the Event_sc
MySQL can implement timed triggering functions, such as what to do with a MySQL database at a certain time, or how often to do what work.The second case is widely used, for example, I would like to check my data information every day, more than one months of useless information to clear up to make room for other storage data to use, or a period of time to update the data and so on.The following discussion o
This article mainly introduces the basic learning tutorial of MySQL triggers, including the basic knowledge of trigger creation and management! For more information, see
0. basic concepts of triggersA trigger is a special stored procedure that triggers execution when inserting, deleting, or modifying data in a specific
MYSQL Tutorial: There are many reasons for running multiple MySQL servers to run multiple servers. for example, the above mentioned restriction can bypass the maximum file descriptor, there are also version tests and dedicated services.
Running multiple servers is much more complex than running a single server. pay attention to the following issues:
When install
PHP + MYSQL member system development instance tutorial, mysql instance tutorial. PHP + MYSQL member system development example tutorial, mysql instance
PHP connection and Operation MySQL database basic tutorial, MySQL basic tutorial
Start from here
What is my blog, background database? Yes, it is MySQL, the server side of the script is PHP, the entire framework uses WordPress. PHP and
Mysql cursor example mysql cursor simple tutorial, mysql cursor example tutorial
From mysql V5.5, a major change was made, that is, InnoDB was used as the default storage engine. InnoDB supports transactions and has the relevant
Quick understanding of the application of triggers in MySQL database tips: when a new integer is added to the database domain, the code segment that automatically updates the total number of running tasks is a trigger. The SQL command block that automatically records changes to a special database table is also a trigger instance.
Ultra-detailed mysql graphic installation tutorial and mysql graphic tutorial
MySQL is a relational database management system developed by MySQL AB in Sweden and currently belongs to Oracle.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.