Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query to check if trigger exist on a MYSQL table

Is there a query which lists all the triggers created for any event on a particular table.

Say I have a table named client, and I want to list all the triggers creared for any event(say insert/update/delete etc) on that table.

Any kind of help is appreciated

like image 946
Sashi Kant Avatar asked Jan 21 '13 11:01

Sashi Kant


People also ask

How do I know if a trigger is working in MySQL?

select * from INFORMATION_SCHEMA. TRIGGERS where EVENT_OBJECT_TABLE='client';

How do you check if a value exists in a table in MySQL?

To test whether a row exists in a MySQL table or not, use exists condition. The exists condition can be used with subquery. It returns true when row exists in the table, otherwise false is returned. True is represented in the form of 1 and false is represented as 0.

How can I see my triggers?

To view database level triggers, Login to the server using SQL Server management studio and navigate to the database. Expand the database and navigate to Programmability -> Database Triggers. To view triggers at the server level, Login to Server using SSMS and navigate to Server Objects and then Triggers folder.


2 Answers

The accepted answer is correct and the most straightforward method, but for an enhanced view of the triggers on a table and more control over what is returned, use INFORMATION_SCHEMA:

select * from INFORMATION_SCHEMA.TRIGGERS where EVENT_OBJECT_TABLE='client';

With this, you can filter on things like EVENT_OBJECT_TABLE (table name), TRIGGER_SCHEMA, EVENT_MANIPULATION (insert, update, delete, etc), and a slew of other attributes.

As pointed out in the comments above, you'll need to have TRIGGER permissions for this method as well.

like image 161
jshrimp29 Avatar answered Oct 20 '22 01:10

jshrimp29


SHOW TRIGGERS

SHOW TRIGGERS LIKE '<tablename>'

e.g.

SHOW TRIGGERS LIKE 'client'
like image 20
Mark Baker Avatar answered Oct 20 '22 02:10

Mark Baker