🔥🚀đŸ“£ Solar Raid Promo! | Summer Special Shared Hosting Sale - 85% OFF | Starting from $1.20/mo
Learn cPanel

Controlling your Web Hosting Account has never been that easy thanks to cPanel web Control Panel!

• Last Updated: 04/29/2020
• ( 3 minutes reading )

What is a Database Trigger and how to add Database Triggers in phpMyAdmin?

Introduction

A database trigger is a stored code sequence that is automatically executed each time a specific event is triggered within a database table. Examples of such events are the UPDATE, INSERT, or DELETE statements. Standard usage of a MySQL trigger could be to perform a check whenever a value is inserted inside a table or to calculate values that are involved in a table update. In this tutorial, we are going to introduce the procedure of creating triggers using the phpMyAdmin service in your cPanel. Let us get started!

 

Accessing phpMyAdmin

Before you can access the PHPMyAdmin functionality, you need to log into your cPanel account with us. To do so, please check our tutorial on How to access the cPanel service.

Once logged in, please navigate to the “Database” section and click on the “phpMyAdmin” icon. 

 

Access phpMyAdmin

 

Clicking on the result redirects you to the “PHPMyAdmin” feature. In the left sidebar, you can see a list of all your databases.

 

Database List

 

Please select the database you want to create the trigger for.

 

Creating a Database Trigger

Once you have selected the database, all its tables are listed in the middle of the screen.

 

Access Triggers tab

 

From the bar on top, please click on the “Triggers” tab. This action takes you straight to the page, which allows you to add a database triggers.

 

Add Database Trigger

 

On the top, you can see the “Triggers” section where all the existing triggers are shown. If there are no triggers created, like in our case - it is empty. To add a trigger, please click the “Add trigger” button located under the “New” section.

This action shows a popup window, which allows you to configure your new database trigger.

 

Database Trigger Details

 

Below, we are going to cover the majority of the options provided in the popup window.

  • Trigger name - In this text field, please type in the name of your trigger. A common practice is to use a name relevant to the trigger’s functionality.
  • Table - Please use the dropdown menu to select which table the database trigger is intended for.
  • Time - Please use the dropdown menu to select when you want this trigger to be activated - BEFORE or AFTER.
  • Event - Please use the dropdown menu to set the event, which activates the trigger.
  • Definition - In this content box, please type in the SQL code you want to be executed when the trigger is activated.
  • Definer - Please use this text field to set the definer of the trigger.

After you have configured your trigger, please press the “Go” button to create it.

 

Create Database Trigger

 

When the database trigger is created, it is displayed under the “Triggers” section within the “Triggers” tab.

 

Database Triggers Location

 

On the row where the trigger is located, you can see 3 buttons. Let’s go over all of them.

  • Edit - Clicking on the “Edit” button opens the previously mentioned popup window allowing you to change the current trigger.
  • Drop - Clicking on the “Drop” deletes the trigger.
  • Export - Clicking on the “Export” button exports a file containing the SQL code of this trigger.

 

And there you have it! This is the way you can use phpMyAdmin to create database triggers. If you are facing any technical issues with this functionality, please do not hesitate to contact our technical support staff over the ticking system in your Client Area.

 

 

...
Sebahat
Technical Support Captain & Content Manager

Sebahat is a young and bright person who had become an invaluable part of our team. Started as a Customer Care Representative who quickly evolved into a Tech-savvy well familiar with every support layer of the company. Driven by the aim to constantly improve our customers’ experience she is committed to enhancing the extraordinary support we deliver.