One, the advantages of the trigger1, the " automatic " of the triggerTo the programmer, the trigger is not visible, but he did do things, if you do not use a trigger, you update the user table name field, you also write code to update other tables
Trigger (Trigger): Monitors a situation and triggers an action.Show triggers; View all triggers drop trigger triggername; Delete TriggerTrigger creation syntax four elements:1. Monitoring Location (table)2. Monitoring Events
Trigger statements exported in multiple sql: DROP TRIGGER IF EXISTS ' t_trig ';D elimiter//create TRIGGER ' T_trig ' before INSERT on ' t_goods ' for each RO W Beginset new.add_date = current_date (); INSERT into test2 SET a2 = new.id;end//delimiter;
Grammar:Trigger on the INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger)CREATE TRIGGER [schema_name.] Trigger_nameOn {table | view}[With [,... N]]{for | After | INSTEAD of}{[INSERT] [,] [UPDATE] [,] [DELETE]}[With APPEND][Not for
1. A simple example
1.1. Create a table:
Create Table T (S1 integer );
1.2. Trigger:
delimiter |create trigger t_trigger before insert on t for each row begin set @x = "hello trigger"; set NEW.s1 = 55;end; |
1.3. If a trigger creation error
1. A trigger is a special stored procedure. It cannot be explicitly called. Instead, it is automatically activated when a record is inserted, updated, or deleted into the table.Therefore, triggers can be used to implement complex integrity
One: A trigger is a special stored procedure that cannot be invoked explicitly, but is automatically activated when you insert records into a table ﹑ update records or delete records. So triggers can be used to implement complex integrity
One: A trigger is a special stored procedure that cannot be invoked explicitly, but is automatically activated when you insert records into a table ﹑ update records or delete records. so triggers can be used to implement complex integrity
MySQLAdvanced Operations (bottom)V.MySQL preprocessing statements1 , setting up preprocessing stmt , passing a data as where the judging conditionsPrepare stmt from "SELECT * FROM table_name where ID >?";2 , set a variableSet @i = 1;3 , execute
One: A trigger is a special stored procedure that cannot be invoked explicitly, but is automatically activated when you insert records into a table ﹑ update records or delete records. So triggers can be used to implement complex integrity
Triggers are an important tool in SQL Server database application and a special type of stored procedure, which is widely used. General stored procedures are called directly through stored procedure names, and triggers are executed through events.
Create triggers. The syntax for creating triggers is as follows:
CREATE TRIGGER trigger_name trigger_time trigger_event
On tbl_name for each ROW trigger_stmt
Where the trigger_name identifies the trigger name and is specified by the user;
Trigger an action when a table is being hacked with a trigger1. Basic statement (also need to modify delimiter)#插入前: Create Trigger T1_i_b (trigger name) before insert on info (table name) each rowbegin ... end# insert create TRIGGER t1_i_a
ViewA view is a virtual table (not a real one), which is essentially "getting a dynamic dataset from an SQL statement and naming it", which allows the user to get a result set using only "name" and use it as a table.Temporary table SearchSELECT
SQL Server trigger details, SQL Server trigger
Trigger is a method provided by SQL server to programmers and data analysts to ensure data integrity. It is a special stored procedure related to table events, its execution is not called by a program,
Basic syntax and functions of triggers in SQLSever, and sqlsever triggers
What is a trigger?
A trigger is a stored procedure that is automatically executed when a table is inserted, updated, or deleted. A special stored procedure that is
The following articles mainly describe the detailed usage and case analysis of MySQL triggers. At the same time, this article also lists some code in the actual operations of MySQL triggers, the following is a detailed description of the article.
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.