From the course: Learning phpMyAdmin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a trigger

Creating a trigger

From the course: Learning phpMyAdmin

Start my 1-month free trial

Creating a trigger

- A trigger is a special type of stored program that fires when a table is modified by an insert, update, or delete statement. This can be useful for validating data or for logging changes to a table. To demonstrate how to create a trigger in phpMyAdmin let's create a simple logging system. For that we need to add a new table to the up_and_running database, so select the database in the panel on the left, then go to the Import tab, and under File to Import, Choose File. We need to go to the Exercise Files, chapter seven folder, and then the 07_05 folder. There's that file there, update_log.sql. Select that, go back to phpMyAdmin, scroll down in the Import tab, and click Go. And that's created the new table. It's listed here on the left, update_log. Let's take a look at it. Go to the Structure tab. And it's got three columns, user_account, updated, and action. User_account and action are both varchar text columns, and updated is a timestamp data type, and it's Default value is the…

Contents