[Niuyun Video] SQL trigger and niuyun SQL trigger

Source: Internet
Author: User

[Niuyun Video] SQL trigger and niuyun SQL trigger

I learned about the data center management system. I have already written about database operations in the net version, but now I am learning about it, only to find that I have understood it too easily. Many things seem to be okay, this article will summarize how to create an SQL trigger from the beginning to the end instead of the Code. The following uses sql2008r2 as an example:
Step 1: Create a trigger
Find the table where you want to create the trigger-New trigger.

Step 2: Fill in the required information
After you click Create trigger, some initialization Code created for the database will appear, as follows:
What we need to write is to start with create trigger. For example, we need to delete table B after Table A is deleted, assume that the auto-increment id of the AB table is the same, the statement is as follows:
Create trigger trigADelete (TRIGGER name, you can write it yourself) on a (Table A is operated) after delete (AFTER Table A is deleted) ASBEGIINdelete B where id = (select id from A where statement for deleting Table A information) END
Other statements, such as search and addition, are similar. After the statements are compiled, run them once, and our triggers are successfully created.
The creation of a trigger is so simple. However, if you do not do anything simple, it will eventually become difficult! So, if you want to learn something, you can do it to gain more benefits!

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.