Domanda

Qual è il comando per elencare tutti i trigger in un database MySQL?

È stato utile?

Soluzione

Il comando per elencare tutti i trigger è:

show triggers;

oppure puoi accedere al INFORMATION_SCHEMA tabella direttamente da:

select trigger_schema, trigger_name, action_statement
from information_schema.triggers

Altri suggerimenti

È possibile utilizzare di seguito per trovare una definizione di trigger particolare.

SHOW TRIGGERS LIKE '%trigger_name%'\G

o il seguente per mostrare tutti i trigger nel database.Funzionerà con MySQL 5.0 e versioni successive.

SHOW TRIGGERS\G

Spero che il seguente codice ti fornisca maggiori informazioni.

select * from information_schema.triggers where 
information_schema.triggers.trigger_schema like '%your_db_name%'

Questo ti darà un totale di 22 colonne Versione MySQL:5.5.27 e al di sopra

TRIGGER_CATALOG 
TRIGGER_SCHEMA
TRIGGER_NAME
EVENT_MANIPULATION
EVENT_OBJECT_CATALOG
EVENT_OBJECT_SCHEMA 
EVENT_OBJECT_TABLE
ACTION_ORDER
ACTION_CONDITION
ACTION_STATEMENT
ACTION_ORIENTATION
ACTION_TIMING
ACTION_REFERENCE_OLD_TABLE
ACTION_REFERENCE_NEW_TABLE
ACTION_REFERENCE_OLD_ROW
ACTION_REFERENCE_NEW_ROW
CREATED 
SQL_MODE
DEFINER 
CHARACTER_SET_CLIENT
COLLATION_CONNECTION
DATABASE_COLLATION

Per mostrare un trigger particolare in uno schema particolare puoi provare quanto segue:

select * from information_schema.triggers where 
information_schema.triggers.trigger_name like '%trigger_name%' and 
information_schema.triggers.trigger_schema like '%data_base_name%'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top