Skip to content
Cyblance
Cyblance
  • Home
  • Auction Platform
  • E-commerce Solution
  • Custom Software
  • Company
    • About Us
    • Video Testimonials
Get Quote

Contact Us

+91 079-49217148 (INDIA) +1 724-251-5115 (USA) info@cyblance.com Unit – 6, Sakar 7 Nehru Bridge Corner, Ahmedabad – 380009 Gujarat, India.

Follow Us

© 2026 Cyblance Technologies Pvt. Ltd. All rights reserved.

Get Quote
setup triggers in Mysql
Mysql, Software Development, Web Development

How to Use triggers in my SQL

How to setup triggers in Mysql?

A trigger is a set of actions that are run automatically when a particularized change operation (SQL INSERT, UPDATE, or DELETE statement) is executed on a specified table. Triggers are beneficial for tasks such as implementing business rules, authorizing input data, and preserving an audit trail.

Types of Triggers

There are following different types of triggers in SQL, all of them can be encrypted for further security.  

  1. Insert
  2. Delete
  3. Update

Advantages of Triggers

  • Triggers help to improve the data integrity by minimizing the errors by checking the manipulation of the data according to business rules when certain actions performed on data.
  • Triggers are very useful to audit the changes of data in the table.

How to use Triggers

  • The syntax of the basic trigger is

CREATETRIGGER name ONtable
  [WITH ENCRYPTION]
  [FOR/AFTER/INSTEAD OF]
  [INSERT, UPDATE, DELETE]
  [NOTFORREPLICATION]

END  

Create Table

  • First, we will create the table for which the trigger is executed.
mysql> CREATE TABLE Cyblance Employees (age INT, name varchar(150));
  • Now, we will define the trigger. It will be executed before every Insert statement for the Cyblance employees table.

mysql> CREATE TRIGGER agecheck BEFORE INSERT ON Cyblance Employees FOR EACH ROW IF NEW.age < 0 THEN SET NEW.age = 0; END IF;//

Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;

  • Now we will insert the records to check the trigger functionality

mysql> INSERT INTO people VALUES (0, ‘vipul’), (27, ‘anil’),(22, ‘Nigam’);

Query OK, 3 rows affected (0.00 sec)

Records: 3 Duplicates: 0 Warnings: 0

  • At the end we will check the resultAt the end we will check the result.

mysql> SELECT * FROM people;

+——-+——-+

| age | Employee name |

+——-+——-+

| 0 | Vipul |

| 27 | Anil

|22 |Nigam

+——-+——-+

3 rows in set (0.00 sec)

Practice triggers to execute business rules, or to complete actions that have either a definite impact on the organization or if an action will hinder enigmas with the system.

Well, may be not before you go through this informative article that explains it right from the basics.Click here for more details.

 

Categories

  • 500 Internal Server
  • Agile Development Process
  • Analysis
  • Android
  • Artificial intelligence
  • ASP.Net
  • Blockchain
  • CakePHP
  • Car dealership
  • Case Study
  • Chatbot
  • Cloud Computing
  • Cloudbed
  • CMS
  • Codeigniter
  • CRM
  • Custom Software
  • Cyber Security
  • Database Normalization
  • Digital Marketing
  • Digital signature
  • Drupal Developers
  • e Commerce Website Development
  • Edge Computing
  • Email Marketing
  • Flutter
  • Goodbye 2018
  • Google API Vs Bing API
  • Hire Developers
  • HTML5
  • HTTP error
  • Instagram Checkout
  • Ionic
  • IOT Application
  • iPhone
  • IT management
  • iWatch
  • Joomla Developers
  • jQuery
  • Laravel
  • Laravel Horizon
  • linkshare
  • Machine Learning
  • Mobile Application
  • Mysql
  • Normalization
  • Organic Search
  • Payment Gateway
  • PCI Compliance
  • PHP framework
  • Prototype Design
  • Python
  • Quality Assurance
  • React Native
  • Responsive
  • Robotic Process Automation
  • SAAS Software
  • SEO (Search Engine Optimization)
  • Shopify
  • Software Development
  • Squarespace
  • System Analysis
  • UI/UX Design
  • Unicommerce
  • Vue.js
  • Waterfall Development Process
  • web application
  • Web Design
  • Web Development
  • Weebly
  • Wireframe
  • Wix
  • Woocommerce
  • Wordpress
  • WordPress Development
  • wordpress-Multi Website
  • WP Plugin
top
Cyblance

Phone:

+91 079-49217148 (INDIA)+1 724-251-5115 (USA)

Email:

info@cyblance.com

Address:

Unit – 6, Sakar 7 Nehru Bridge Corner, Ahmedabad – 380009 Gujarat, India.

Quick Links

  • Services
  • Solutions
  • Case Studies
  • Blogs
  • About Us

Support

  • Contact Us
  • Careers
  • FAQ
  • Privacy Policy
  • Sitemap

Our Services

  • Auction Platform
  • Custom Software
  • E-commerce Solution
  • White-Label Solutions
DMCA.com Protection Status

Copyright © Cyblance Technologies Pvt. Ltd. All rights reserved

PhoneWhatsApp