11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 33 • MYSQL TRIGGERSwww.it-ebooks.infoEVENT_OBJECT_SCHEMA: chapter33EVENT_OBJECT_TABLE: techniciansACTION_ORDER: 0ACTION_CONDITION: NULLACTION_STATEMENT: beginif NEW.available = 0 THENUPDATE tickets SET technician_id=0 WHERE technician_id=NEW.id;END IF;ENDACTION_ORIENTATION: ROWACTION_TIMING: AFTERACTION_REFERENCE_OLD_TABLE: NULLACTION_REFERENCE_NEW_TABLE: NULLACTION_REFERENCE_OLD_ROW: OLDACTION_REFERENCE_NEW_ROW: NEWCREATED: NULLSQL_MODE: STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTIONDEFINER: root@localhostCHARACTER_SET_CLIENT: latin1COLLATION_CONNECTION: latin1_swedish_ciDATABASE_COLLATION: latin1_swedish_ciAs you can see, the beauty of querying the INFORMATION_SCHEMA database is that it’s so much moreflexible than using SHOW TRIGGERS. For example, suppose you are managing numerous triggers and wantto know which ones triggered after a statement:SELECT trigger_name FROM INFORMATION_SCHEMA.triggers WHERE action_timing="AFTER"Or perhaps you’d like to know which triggers were executed whenever the technicians table was thetarget of an INSERT, UPDATE, or DELETE query:mysql>SELECT trigger_name FROM INFORMATION_SCHEMA.triggers WHERE->event_object_table="technicians"Modifying a TriggerAt the time of writing, there was no supported command or GUI application available for modifying anexisting trigger. Therefore, perhaps the easiest strategy for modifying a trigger is to delete andsubsequently re-create it.Deleting a TriggerIt’s conceivable, particularly during a development phase, that you’ll want to delete a trigger or removeit if the action is no longer needed. This is accomplished by using the DROP TRIGGER statement, theprototype of which follows:DROP TRIGGER [IF EXISTS] table_name.trigger_name656

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!