SQL Server triggers simple learning notes

Source: Internet
Author: User

Triggers are special stored procedures that run in the database, but cannot invoke triggers by calling names, and triggers are automatically responded to.

a trigger is also a transaction, where an error is rolled back .

Triggers are divided into DDL triggers and DML triggers

1: Different Trigger objects:

A DML trigger belongs to a table or view; a DDL trigger belongs to a database or server.

2: Different trigger modes:

DML triggers operate on Insert, Update, and Delete statements and can be used as after triggers and Instead of triggers.

DDL triggers perform operations on Create, Alter, Drop, and other DDL statements, as well as stored procedures that perform DDL-type operations, only as after triggers and not instead OF triggers.

3: System response mechanism is different:

DML triggers get actions that trigger events by accessing dynamic tables inserted and deleted.

DDL triggers capture triggered events that activate DDL triggers and subsequent change information caused by triggers by using the EVENTDATA function.

4: Different trigger times:

The DML trigger responds with an Insert,update,delete event that executes automatically.

DDL triggers respond to two types of events: The event that begins with Create,alter,drop, and the Grant,deny,revoke event for the Data Control language.

After trigger mode with instead OF trigger mode

After triggers are fired after processing the trigger action (Insert, Update, or Delete), Instead of triggers, and constraints. Instead of is to be fired before processing the constraint in place of the triggering action.

SQL Server triggers simple learning notes

Related Article

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.