From the course: MySQL Advanced Topics
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Creating a stored procedure - MySQL Tutorial
From the course: MySQL Advanced Topics
Creating a stored procedure
- [Bill] Hi, I am Bill Wineman. A stored procedure is defined with the create procedure statement. I've copied this block of SQL from the chapter three exercise file, and we'll use the album database for this. And here we have a simple procedure. This procedure is called list_albums and I start by doing a drop procedure if exists, because we're going to create several versions of this as we go through this lesson. You'll notice we use the delimiter command again, and this sets a delimiter in this case to a double slash, but you can set it to whatever you like, and that allows you to have semicolons in your code that you send to the server. And then we set the delimiter back at the end. Create procedure is very simple, you create procedure, you give it the name and parentheses which we'll have parameters, we'll discuss parameters later in this lesson. And then you simply have your SQL statement, terminated by a semicolon and then end with our terminator and then setting our delimiter…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.