A trigger (trigger) is a method that SQL Server provides to programmers and data analysts to ensure data integrity, which is a special stored procedure related to table events, which is executed either by a program call or by a manual startup, but by an event, such as when a table is manipulated ( Insert,delete, update) will be activated when it executes. Triggers are often used to enforce data integrity constraints, business rules, and so on. Triggers can be found in the dba_triggers, user_triggers data dictionary. The SQL3 trigger is a statement that can be automatically executed by the system to modify the database. Triggers can query other tables and can contain complex SQL statements. They are primarily used to enforce complex business rules or requirements. For example, you can control whether a new order is allowed to be inserted based on the current account status of the customer. Triggers can also be used to enforce referential integrity so that when rows are added, updated, or deleted in multiple tables, the relationships defined between the tables are preserved. However, the best way to enforce referential integrity is to define primary key and foreign key constraints in related tables. If you use a database diagram, you can create relationships between tables to automatically create foreign key constraints. The only difference between a trigger and a stored procedure is that the trigger cannot execute the EXECUTE statement call, but instead automatically triggers execution when the user executes the Transact-SQL statement.
/********************************** above is a copy of the *******************************/
First create two test tables ceshi1_table ceshi2_table
My goal is to change the phone in ceshi1_table when Ceshi2_table's phone will change.
PS: Phone number I won't be exposed.
And then I'm going to create my trigger.
The result was a mistake.
Lookup Data discovery, table-level triggers are not available: New and: Old, and: New and: The can only be used in a row trigger, so you need to add the for each row before begin
That's how it works.
Change ceshi1_table ceshi2_table also changed!!!
Oracle Trigger Learning