- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between stored procedure and triggers in SQL
Stored procedures are a pieces of the code in written in PL/SQL to do some specific task. Stored procedures can be invoked explicitly by the user. It's like a java program , it can take some input as a parameter then can do some processing and can return values.
On the other hand, trigger is a stored procedure that runs automatically when various events happen (eg update, insert, delete). Triggers are more like an event handler they run at the specific event. Trigger can not take input and they can’t return values.
Sr. No. | Key | Triggers | Stored procedures |
---|---|---|---|
1 | Basic | trigger is a stored procedure that runs automatically when various events happen (eg update, insert, delete) | Stored procedures are a pieces of the code in written in PL/SQL to do some specific task |
2 | Running Methodology | It can execute automatically based on the events | It can be invoked explicitly by the user |
3 | Parameter | It can not take input as parameter | It can take input as a parameter |
4 | Transaction statements | we can't use transaction statements inside a trigger | We can use transaction statements like begin transaction, commit transaction, and rollback inside a stored procedure |
5 | Return | Triggers can not return values | Stored procedures can return values |