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
Delete trigger
DROP TRIGGER tr_update_Stock
Disable
ALTER TABLE trig_example DISABLE TRIGGER trig1 GO
Recovery
ALTER TABLE trig_example ENABLE TRIGGER trig1 GO
Disable all triggers on a table
ALTER TABLE 你的表 DISABLE TRIGGER all
Enable all triggers on a table
ALTER TABLE 你的表 enable TRIGGER all
Disable all triggers on all tables
exec sp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all'
Enable all triggers on all tables
exec sp_msforeachtable 'ALTER TABLE ? enable TRIGGER all'
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!