Home > Database > Mysql Tutorial > How to use triggers in sql

How to use triggers in sql

青灯夜游
Release: 2020-09-16 15:27:26
Original
4496 people have browsed it

How to use triggers in sql

Usage of triggers

A trigger is a special stored procedure that occurs when the user attempts to Automatically executed when the table executes the specified data modification statement. You can use the CREATE statement to create a trigger, the DROP statement to delete the trigger, the ALTER statement to disable the trigger, etc. Let’s introduce it in detail below.

Create trigger

CREATE TRIGGER tr_update_Stock
Copy after login

Delete trigger

DROP  TRIGGER tr_update_Stock
Copy after login

Disable

ALTER TABLE trig_example DISABLE TRIGGER trig1
GO
Copy after login

Recovery

ALTER TABLE trig_example ENABLE TRIGGER trig1
GO
Copy after login

Disable all triggers on a table

ALTER TABLE 你的表 DISABLE TRIGGER all
Copy after login

Enable all triggers on a table

ALTER TABLE 你的表 enable TRIGGER all
Copy after login

Disable all triggers on all tables

exec sp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all'
Copy after login

Enable all triggers on all tables

exec sp_msforeachtable 'ALTER TABLE ? enable TRIGGER all'
Copy after login

The above is the detailed content of How to use triggers in sql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template