SlideShare a Scribd company logo
Triggers in SQL | Edureka
WHAT IS A TRIGGER?
SYNTAX AND EXAMPLE
OPERATION ON TRIGGERS
ADVANTAGES AND DISADVANTAGES
www.edureka.co
www.edureka.co
Triggers are the SQL codes that are automatically executed in response to certain events on a
particular table. These are used to maintain the integrity of the data.
What is a TRIGGER?
www.edureka.co
WHAT IS A TRIGGER?
Hey Sharan, Do you
know what Triggers
are?
www.edureka.co
WHAT IS A TRIGGER?
www.edureka.co
Well, Let me explain
you in a simple way
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
PROBLEM WITHOUT TRIGGER
www.edureka.co
SOLUTION
www.edureka.co
SOLUTION
www.edureka.co
SOLUTION
www.edureka.co
SOLUTION
www.edureka.co
SOLUTION
www.edureka.co
www.edureka.co
SYNTAX
OF TRIGGER
www.edureka.co
Create Trigger Trigger_Name
(Before | After)
[ Insert | Update | Delete]
on [Table_Name]
[ for each row | for each column ]
[ Trigger_body ]
EXAMPLE
OF TRIGGER
CREATE TRIGGER sample_trigger
before INSERT
ON student
FOR EACH ROW
SET new.marks = new.marks+6;
www.edureka.co
NESTED TRIGGERS
www.edureka.co
Nested Triggers in
SQL are the actions
that automatically
executed when a
certain database
operation is
performed
www.edureka.co
www.edureka.co
SYNTAX:
DROP TRIGGER trigger name;
EXAMPLE:
DROP TRIGGER calculate name;
We can use DROP
command to remove a
trigger from the
database
DROP
www.edureka.co
We can use SHOW
command to display
triggers from the
database
DISPLAY
SYNTAX:
SHOW TRIGGERS
IN database_name;
EXAMPLE:
SHOW TRIGGERS
IN edureka;
www.edureka.co
SYNTAX:
CREATE TRIGGER calculate
before INSERT
ON student
FOR EACH ROW
SET new.marks = new.marks+100;
Before Insert
Triggers are used
to update or
validate record
values before
they’re saved to
the database
INSERT
www.edureka.co
SYNTAX:
CREATE TRIGGER total_mark
after insert
ON student
FOR EACH ROW
insert into Final_mark values(new.marks);
After Insert
Triggers are used
to access field
values that are set
by the system and
to effect changes
in other records
INSERT
www.edureka.co
ADVANTAGES OF TRIGGERS
02
Triggers check the
integrity of data
01
Forcing security
approvals on the
table
03
Counteracting
invalid exchanges
04
Triggers handle
errors
05
Triggers are useful for
inspecting the data
www.edureka.co
DISADVANTAGES OF TRIGGERS
Overhead
Triggers may increase
the overhead of the
database
Validation
Triggers can only
provide extended
validations, i.e, not
all kind validations
Troubleshoot
Triggers can be difficult
to troubleshoot because
they execute
automatically in the
database
www.edureka.co
www.edureka.co

More Related Content

PPTX
5. stored procedure and functions
PPTX
Trigger in mysql
PPT
Oracle Database Trigger
PPTX
Triggers
DOC
A must Sql notes for beginners
PDF
Informatica question & answer set
PPTX
Inner join and outer join
PPSX
MS SQL Server
5. stored procedure and functions
Trigger in mysql
Oracle Database Trigger
Triggers
A must Sql notes for beginners
Informatica question & answer set
Inner join and outer join
MS SQL Server

What's hot (20)

PDF
PL/SQL TRIGGERS
PPTX
trigger dbms
PPTX
Group By, Having Clause and Order By clause
PPSX
Functional dependency
PDF
Normalization in DBMS
PPT
Advanced sql
PPTX
Aggregate functions in SQL.pptx
PPTX
Sql Functions And Procedures
PDF
Nested Queries Lecture
PPTX
Packages in PL/SQL
PPTX
Integrity Constraints
PPTX
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
PPT
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
PPT
1 - Introduction to PL/SQL
PPT
Using the set operators
PPT
12. Indexing and Hashing in DBMS
PPTX
SQL(DDL & DML)
PPTX
Normal forms
PPT
PL/SQL Introduction and Concepts
PL/SQL TRIGGERS
trigger dbms
Group By, Having Clause and Order By clause
Functional dependency
Normalization in DBMS
Advanced sql
Aggregate functions in SQL.pptx
Sql Functions And Procedures
Nested Queries Lecture
Packages in PL/SQL
Integrity Constraints
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
1 - Introduction to PL/SQL
Using the set operators
12. Indexing and Hashing in DBMS
SQL(DDL & DML)
Normal forms
PL/SQL Introduction and Concepts
Ad

Similar to Triggers in SQL | Edureka (20)

PDF
triggeroracle-eryk-130621201822-phpapp01.pdf
PPT
TRIGGERS IN DATABASE MANAGEMENT SYSTEM.ppt
PPT
Trigger
PPT
Module06
PDF
Lecture Notes Unit5 chapter16 Trigger Creation
PDF
Triggers in PL introduction yo database s
PPTX
PPTX
6. triggers
PDF
[Www.pkbulk.blogspot.com]dbms11
PPT
Mca ii-dbms-u-v-transaction management
PPT
11303 dbms chap_02_triggers (2)
PDF
AskTOM Office Hours on Database Triggers
PPTX
basicofunit-4-250728105436-7464afe1.pptx
PPTX
basicofunit-4-250728105436-7464afe1.pptx
PPTX
Basic information of unit-4 form of ppt.
PPTX
triggers.pptx
PPT
plsql les10
PDF
Triggers (1).pdf
PPTX
27e79b9c27c0a33bfenjdnddcvfdrrfrcddccd.pptx
PPT
plsql Lec11
triggeroracle-eryk-130621201822-phpapp01.pdf
TRIGGERS IN DATABASE MANAGEMENT SYSTEM.ppt
Trigger
Module06
Lecture Notes Unit5 chapter16 Trigger Creation
Triggers in PL introduction yo database s
6. triggers
[Www.pkbulk.blogspot.com]dbms11
Mca ii-dbms-u-v-transaction management
11303 dbms chap_02_triggers (2)
AskTOM Office Hours on Database Triggers
basicofunit-4-250728105436-7464afe1.pptx
basicofunit-4-250728105436-7464afe1.pptx
Basic information of unit-4 form of ppt.
triggers.pptx
plsql les10
Triggers (1).pdf
27e79b9c27c0a33bfenjdnddcvfdrrfrcddccd.pptx
plsql Lec11
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka

Recently uploaded (20)

PPTX
Machine Learning_overview_presentation.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Machine learning based COVID-19 study performance prediction
PDF
Approach and Philosophy of On baking technology
PPTX
Tartificialntelligence_presentation.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
Teaching material agriculture food technology
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Machine Learning_overview_presentation.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine learning based COVID-19 study performance prediction
Approach and Philosophy of On baking technology
Tartificialntelligence_presentation.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Teaching material agriculture food technology
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation_ Review paper, used for researhc scholars
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25-Week II
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf

Triggers in SQL | Edureka