Database Reference
In-Depth Information
Nonetheless, if we prefer to see a more exact row count for views, we can put a larger
value in this parameter which acts as an upper limit for the rows counting phase.
Routines—stored procedures and
functions
It took a while before phpMyAdmin started to include support for these features.
The reason is that stored procedures and functions are blocks of code (like a
subprogram) that are kept as part of the database, and phpMyAdmin, being a web
interface, is more oriented towards operations that are done quickly using a mouse.
Nonetheless, phpMyAdmin has a few features that permit a developer to create such
routines, save them, recall them to make some modifications, and then delete them.
Procedures are accessed by a CALL statement to which we can pass parameters. On
the other hand, functions are accessed from SQL statements (for example, SELECT ),
similar to other MySQL internal functions returning a value.
The CREATE ROUTINE and ALTER ROUTINE privileges are needed
to be able to create, see, and delete a stored procedure or function. The
EXECUTE privilege is needed to run the routine, although the privilege
is normally granted automatically to its creator.
Creating a stored procedure
We'll create a procedure to change the page count for a specific book, by adding a
specific number of pages. The book's ISBN and the number of pages to be added,
will be the input parameters to this procedure.
Changing the delimiter
The standard SQL delimiter is the semicolon, and this character will be used
inside our procedure to delimit SQL statements. However, the CREATE PROCEDURE
statement is by itself an SQL statement; hence, we must come up with a way to
indicate to the MySQL parser where this statement ends. The query box has a
Delimiter input box, which contains a semicolon by default. Therefore, we change it
to another string, which, by convention, is a double slash // .
 
Search WWH ::




Custom Search