Oracle Trigger Learning

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.