Typically used to detect inserted values when inserting a table, or to calculate a value on update.The app can be manipulated when insert,update,delete a tableGrammar:Creating a trigger CREATE TRIGGER trigger name Before/after insert/update/delete on table name for each row SQL statementSuch as:Create trigger Cal_num b
Label:Three after triggers DROP TABLE IF EXISTS tab1;CREATE TABLE Tab1 (tab1_id varchar (11),Tab1_name varchar (11),Tab1_pass varchar (11));DROP TABLE IF EXISTS tab2;CREATE TABLE TAB2 (tab2_id varchar (11),Tab2_name varchar (11),Tab2_pass varchar (11));--Add after insert triggerDROP TRIGGER IF EXISTS t_afterinsert_on_tab1;CREATE TRIGGER T_AFTERINSERT_ON_TAB1After INSERT on TAB1For each ROWBEGINInsert into
correct.The reasons are: to assign values to multiple variables through a SELECT statement, use the following statement form: Select Id,name into @v1, @v2 from ...So eventually I changed to the following way:CREATE TRIGGER IstmingxiAfter UPDATE on Sys_shenbao for each ROW BEGINSELECT Jl.skid,shen.gonghao,jl.vuid,ct.leibie,ct.bianhao,ct.fenshu,zl.bumen,shen.verifytimeInto @kid, @gonghao, @vuid, @zhibiao, @citiao, @fenshu, @bumen, @ctimeFrom Sys_shenba
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;CREA
How to use mysqldump to export a Trigger
Description:When using mysqldump to export a Trigger, you may encounter a problem and paste it to avoid mistakes. When you perform the following operations:[Root @ ytt ~] #/Usr/local/mysql/bin/mysqldump-S/tmp/mysql1.sock test> test. SQLThe exported result contains the Trigger
How to use mysqldump to export a Trigger
Description:When using mysqldump to export a Trigger, you may encounter a problem and paste it to avoid mistakes. When you perform the following operations:[Root @ ytt ~] #/Usr/local/mysql/bin/mysqldump-S/tmp/mysql1.sock test> test. SQLThe exported result contains the Trigger
Label: first, the concept of triggers A trigger is a special stored procedure, in which the stored procedure is invoked with call, and the trigger does not need to be called, nor does it need to be started manually, as long as a predefined event occurs and is automatically called by MySQL. A trigger is a special kind o
Mysql uses a trigger to synchronize two tablesCurrently, the local test is successful.Assume that two local databases a and B have table1 (id, val) and table2 (id, val) in table)Assume that you want to synchronize data updates in table 1 and table 2.Code:DELIMITER $CREATE/* [DEFINER = {user | CURRENT_USER}] */TRIGGER 'A'. 'tr
Tags: info result share picture SQL not from trigger data version issue "MySQL must know" in the trigger chapter using the code to create the trigger error in MySQL5.7.20: Error 1415 (0a000): Not allowed to return a result set from a trigger.Because I don't know if this is a version issue, I put double quotes on the e
Tags: functions mysql stored procedureMySQL stored procedures and function stored proceduresDownloadDemoMysql> delimiter//--here//To modify the default delimiter;
mysql> CREATE PROCEDURE simpleproc (out param1 INT)
begin
, SELECT COUNT (*) to param1 from T;
end//
Query OK, 0 rows Affected (0.00 sec)
mysql> delimiter; --Change back here the default delimite
time to spend 1s, trigger trigger modification will trigger 500 times, add 1s per row of data modification, then the trigger will cost 500s.
During the test, we found that after inserting a row of data in the INSERT, the trigger could not be applied to the update o
Does mysql condition use or query trigger index? The statement is: the where condition contains or and does not use indexes. the test results are as follows: mysql gt; nbsp; explain nbsp; select nbsp; * nbsp; from nbsp; emp nbsp; where nbsp; ename = "dsleos" nbsp; mysql condition use or query will not
The following articles mainly describe the actual application of MySQL triggers and the actual operations of their stored procedures. The following articles will provide you with detailed solutions, the following is a detailed description of the relevant content. I hope it will help you in this regard.
Trigger:
Create a trigger for a
Select PF (8); Delete function drop functions pf;Drop function if exists pf; View code when the PF function is established show create function ff;View--Show student number name grade grade substitute teacher name if no teacher shows no teacher-definition view Create views Vvasselect sid,sname,sscore,case when Sscore was null then ' retake ' whe n Sscore >=90 Then ' excellent ' when sscore>=80 then ' good ' when sscore>=60 then ' Pass ' when sscore--Query view rather query a data table, view on
Q: How can I use Slave to filter delete operations in the MySQL master-Slave replication structure.
Problem Analysis: this problem corresponds to the preservation of all records, including the delete records.
The granularity of MySQL filter rules is accurate to the table granularity.
Different triggers can be used for the master and slave nodes.
Result: Create a before
A MySQL trigger or a stored procedure can call a PHP function.
If there should be write
I have a feature user after the AAP send message insert I want to send a message with a trigger reply
Because our web site data sources have app-side and web-side reply mail is on the web side
Reply to discussion (solution)
MySQL
can't be defined, but it can change its value.What global variables are queriedShow variables;//shows all the global variablesShow variables like ' char% ';? Fuzzy matching QueryQuery a single global variable cannot be used with show, should use SelectSELECT @ @character_set_client;Assign a value to a global variable:SET @ @character_set_client = GBK;?? Valid only in the current link (that is, the current client)1.7.2 Session variable br/> session variable starts with @Set @vall = 10;Must you s
'; DECLARE CONTINUEHANDLER forSQLSTATE'02000' SETDone= 1; OPENCur1; OPENCUR2; REPEATFETCHCur1 intoA, B; FETCHCur2 intoC; IF notDone Then
SELECTA,b,c; END IF; UNTIL DoneENDREPEAT; CLOSECur1; CLOSECur2;ENDTriggerMust be built on top of the real table, suitable for some initialization data CREATE TABLETest1 (A1INT); CREATE TABLETest2 (A2INT); CREATE TABLETEST3 (A3INT not NULLAuto_incrementPRIMARY KEY); CREATE TABLEtest4 (A4INT not NULLAuto_incrementPRIMARY KEY, B4INT DEFAULT 0
); DELIMIT
Mysql uses triggers to synchronize two tables. Currently, the test is successful locally. Www.2cto.com assume that two local databases, a and B, and a have table table1 (id, val) and B have table table2 (id, val). Assume that you want to update data in table 1, synchronously update data in table 2. Code: DELIMITER $ CREATE/* [DEFINER = {user | CURRENT_USER}] */TRIGGER 'A '. '
MySQL Trigger settingsBackground:mysql triggers can trigger actions before or after changes are made to the database data (insert, modify, delete).Prompt when setting up a MySQL trigger:ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging isenabled (you *might* want to use the less safe log_bin_tr
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.