Get the App
SLTechnology News&Howtos  ›  Database  › 

How to delete triggers for mysql databases

Shulou Source: shulou.com Published: 2022-06-01 02:41:18 09月22日 Update

Editor to share with you how to delete mysql database triggers, I hope you will learn a lot after reading this article, let's discuss it together!

In mysql, you can use the "DROP TRIGGER" statement to delete a defined trigger in the syntax format "DROP TRIGGER [IF EXISTS] [database name] trigger name"; when you delete a table, the trigger on that table is also automatically deleted.

Delete trigger

Use the DROP TRIGGER statement to delete triggers that are already defined in MySQL.

The syntax format is as follows:

DROP TRIGGER [IF EXISTS] [database name]

The syntax 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 is located. 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 you delete a table, the trigger on that table is also automatically deleted. In addition, triggers cannot be updated or overwritten, and in order to modify a trigger, you must delete it and then recreate it.

[example] Delete the double_salary trigger, and enter the SQL statement and execution process as shown below.

Mysql > DROP TRIGGER double_salary;Query OK, 0 rows affected (0.03 sec)

When you delete the double_salary trigger and insert the record into the data table tb_emp6 again, the data in the data table tb_emp7 no longer changes, as shown below.

Mysql > INSERT INTO tb_emp6-> VALUES; Query OK, 1 row affected (0.09 sec) mysql > SELECT * FROM tb_emp6 +-A | 1 | 1000 | 2 | B | 1 | 1000 | 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) finished reading this article I believe you have a certain understanding of how to delete mysql database triggers, want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Trigger data database statement syntax at the same time name datasheet permission format article again finished instance situation location more knowledge industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Shulou Information Microsoft Docker