In mysql, you can use the "DROP TRIGGER" statement to delete a defined trigger. The syntax format is "DROP TRIGGER [IF EXISTS] [database name] trigger name"; when deleting a table, it also Triggers on the table are automatically deleted.
(Recommended tutorial: mysql video tutorial)
Delete trigger
Use the DROP TRIGGER statement to delete triggers that have been defined in MySQL.
The syntax format is as follows:
DROP TRIGGER [ IF EXISTS ] [数据库名] <触发器名>
The syntax description is as follows:
1) Trigger name
The name of the trigger to delete.
2) Database name
optional. Specifies the name of the database where the trigger resides. If not specified, it is the current default database.
3) Permissions
SUPER permission is required to execute the DROP TRIGGER statement.
4) IF EXISTS
Optional. Avoid deleting triggers without triggers.
Note: When a table is deleted, the triggers on the table will also be automatically deleted. In addition, triggers cannot be updated or overwritten. In order to modify a trigger, you must first delete it and then recreate it.
[Example]Delete the double_salary trigger. The input SQL statement and execution process are as follows.
mysql> DROP TRIGGER double_salary; Query OK, 0 rows affected (0.03 sec)
After deleting the double_salary trigger, when inserting records into the data table tb_emp6 again, the data in the data table tb_emp7 will no longer change, as shown below.
mysql> INSERT INTO tb_emp6 -> VALUES (3,'C',1,200); Query OK, 1 row affected (0.09 sec) mysql> SELECT * FROM tb_emp6; +----+------+--------+--------+ | id | name | deptId | salary | +----+------+--------+--------+ | 1 | A | 1 | 1000 | | 2 | B | 1 | 500 | | 3 | C | 1 | 200 | +----+------+--------+--------+ 3 rows in set (0.00 sec) mysql> SELECT * FROM tb_emp7; +----+------+--------+--------+ | id | name | deptId | salary | +----+------+--------+--------+ | 1 | A | 1 | 2000 | | 2 | B | 1 | 1000 | +----+------+--------+--------+ 2 rows in set (0.00 sec)
The above is the detailed content of How to delete triggers from mysql database?. For more information, please follow other related articles on the PHP Chinese website!