Database triggers Database triggers are used to do what?

turn

Database triggers what to do?

A trigger is a special type of stored procedure, when one or more of the following data modification operation to modify data in the specified table, the trigger takes effect: UPDATE, INSERT, or DELETE. Triggers can query other tables and can include complex SQL statements. They are mainly used to enforce complex business rules or requirements. For example, you can control whether to allow insertion orders based on the current state of the customer's account. 

Triggers can also help enforce referential integrity, in order to add, update or delete the relationship between the table rows reserved table defined. However, the best way to enforce referential integrity is to define the primary key and foreign key constraints in a related table. If a database diagrams, it is possible to create relationships between tables to automatically create foreign key constraints. For more information, see Table relations. 

Using triggers advantage of 
the advantages of the following triggers: 

Trigger is automatic: they make any modifications to the data table is activated immediately after (such as operating manual input or an application to take). 

Triggers can be stacked by changes in the relevant database table. For example, writing a delete trigger title_id column titles in the table to match each other row in the table to take deletion. The trigger with title_id column as a unique key, each match line positioned in titleauthor, sales and roysched table. 

Triggers can enforce restrictions, more complex with these restrictions CHECK constraint ratio defined. CHECK constraints is different, the trigger may refer to other columns in the table. For example, a trigger can attempt to roll back the price of less than $ 10 book (stored in the titles table) Application Discount 
Released two original articles · won praise 1 · views 235
A trigger is a special type of stored procedure, when one or more of the following data modification operation to modify data in the specified table, the trigger takes effect: UPDATE, INSERT, or DELETE. Triggers can query other tables and can include complex SQL statements. They are mainly used to enforce complex business rules or requirements. For example, you can control whether to allow insertion orders based on the current state of the customer's account. 

Triggers can also help enforce referential integrity, in order to add, update or delete the relationship between the table rows reserved table defined. However, the best way to enforce referential integrity is to define the primary key and foreign key constraints in a related table. If a database diagrams, it is possible to create relationships between tables to automatically create foreign key constraints. For more information, see Table relations. 

Using triggers advantage of 
the advantages of the following triggers: 

Trigger is automatic: they make any modifications to the data table is activated immediately after (such as operating manual input or an application to take). 

Triggers can be stacked by changes in the relevant database table. For example, writing a delete trigger title_id column titles in the table to match each other row in the table to take deletion. The trigger with title_id column as a unique key, each match line positioned in titleauthor, sales and roysched table. 

Triggers can enforce restrictions, more complex with these restrictions CHECK constraint ratio defined. CHECK constraints is different, the trigger may refer to other columns in the table. For example, a trigger can attempt to roll back the price of less than $ 10 book (stored in the titles table) Application Discount 

Guess you like

Origin blog.csdn.net/qq_44301515/article/details/99692692