Welcome to Findnerd. We are going to explain the storage procedure and functions. It is also known as stored routines. Stored routines is available from Mysql5.7.
There is table named proc which is required to work with stored routines. It will be created itself when you install the version Mysql5.7 and above.
It is not required to write the same queries again and again. Queries will be stored on database server. Different applications can run the same stored procedures
as per the requirement. It will increase the load of the databases server because most of work will be done on database server.
Stored routines also provides different libraries on database server. You can simply create and drop the procedures using queries.
DELIMITER //
CREATE PROCEDURE `nerd` ()
LANGUAGE SQL
DETERMINISTIC
SQL SECURITY DEFINER
COMMENT 'A procedure'
BEGIN
SELECT 'Hello World !';
END//
You need to mention the name of the procedure which is case-insensitive and different characteristics of procedure. LANGUAGE for portablilty purpose, Deterministic
for replication, SQL SECURITY for checking privileges of the user,default value is DEFINER, creator of the procedure. COMMENT for documentation purpose. You can
call the stored procedure like this
CALL stored_procedure_name (param1, param2, ....)
0 Comment(s)