Categories: MySQL

Intro: MySQL Stored Procedures

Share

A segment of declarative SQL statements which is stored inside the database catalog is called stored procedures, invoked by a triggers.

Advantages:

  • When stored procedures are created it is compiled and stored in the database so that when it is called multiple times then the compiled version is used.
  • It is very secure.
  • It is reusable.
  • It helps to reduce the traffic between application and database server.

Disadvantages:

  • Developing and maintaining stored procedures are not an easy things.
  • Debugging stored procedures is very difficult.
  • Using lots of stored procedures makes memory usage high.

Example:

DELIMITER //
CREATE PROCEDURE GetAllUsers()
BEGIN
SELECT *  FROM users;
END //
DELIMITER ;

Here GetAllUsers() stored procedure selects all users from the users table.

To call stored procedure:

CALL GetAllUsers();

Recent Posts

The Rise of NFTs: Exploring the Impact of Non-Fungible Tokens on the Digital Economy

NFTs, or Non-Fungible Tokens, are revolutionizing the digital economy. These unique digital assets, authenticated through…

5 hours ago

Unveiling the Truth: Is the Spread of Sinus Infections a Myth or Reality?

Sinus infections, impacting approximately 31 million Americans each year, represent a significant health concern stemming…

1 day ago

Best Exercises To Reduce Weight & Keep You Stronger & Fitter!

No doubt that balanced weight is the key to wellness. So, when it comes to…

1 day ago

ARTIFICIAL INTELLIGENCE: Advantages And Disadvantages? Everything You Need to Know

Pros And Cons Of AI: Artificial Intelligence directly translates to conceptualizing and building machines that…

2 days ago

Four common mistakes when picking an internet provider

We all live on the internet; we use it for everything. Thus, when it comes…

2 days ago

What Is Commonly Misdiagnosed as Pink Eye: Understanding Eye Conditions and Their Symptoms

Introduction: Pink eye, or conjunctivitis, is a common eye condition characterized by redness and inflammation…

2 days ago