From the course: MySQL Advanced Topics (2019)

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Language extensions

Language extensions

- Every SQL system provides its own set of extensions for supporting variables and loops and other features in their stored routines. Here, we'll examine a small sample of essential MySQL extensions. For more details, please see the MySQL online documentation. We're using the Scratch database, we're not actually writing anything to any tables but it does need a database to start procedures in. And our procedure is called str_count. It doesn't have any parameters, because really what I want to show you is how do you declare and use variables and how to use a simple WHILE loop. And so here we have the DECLARE statement, which DECLARE is a variable. The syntax is much like the column definition in a create table statement. And so you have a name for the variable and a type and an optional default value. And I always set a default value if I can because just in case you end up using it before you set it. And here's a simple…

Contents