Book Image

Mastering phpMyAdmin 2.11 for Effective MySQL Management

Book Image

Mastering phpMyAdmin 2.11 for Effective MySQL Management

Overview of this book

Table of Contents (25 chapters)
Mastering phpMyAdmin 2.11 for Effective MySQL Management
Credits
About the Author
About the Reviewers
Preface

Triggers


Triggers are code that we associate to a table to be executed when certain events occur, for example after a new INSERT in table book. The event does not have to happen from within phpMyAdmin.

Contrary to routines that are related to a whole database and visible on the database's Structure page, triggers for each table are accessed from this specific table's Structure page.

Note

Prior to MySQL 5.1.6, we needed the SUPER privilege to create and delete triggers. In version 5.1.6, a TRIGGER table-level privilege was added to the privilege system, so a user no longer needs the powerful SUPER privilege for these tasks.

In order to perform the following exercise, we'll need a new column in our author table, total_page_count.

The idea here is that every time a new book is created, its page count will be added to the author's total page count. I know that some people may advocate that it would be better to not keep a separate column for the total here and compute the total instead, each time...