GPH Theory: Your Ultimate Guide to General Topics, News, SEO, and Technology

Welcome to GPH Theory, your go-to source for the latest news, insights, and analysis on general topics, SEO, technology, and more. Our mission is to provide you with the most relevant and up-to-date information to help you stay ahead of the curve. From beginners to experts, we have something for everyone. Join us and start your journey towards digital excellence today.

MYSQL stored procedure | MYSQL Function | MYSQL stored routines

  Bittu      

 PROCEDURES AND FUNCTIONS

Stored routines require the proc table.

Stored routines can be particularly useful in certain situations:

  1.  When multiple client applications are written in different languages or work on different platforms, but need to perform the same database operations.
  2. When security is paramount. Banks, for example, use stored procedures and functions for all common operations. This provides a consistent and secure environment, and routines can ensure that each operation is properly logged. In such a setup, applications and users would have no access to the database tables directly, but can only execute specific stored routines.

Stored routines can provide improved performance because less information needs to be sent between the server and the client. The tradeoff is that this does increase the load on the database server because more of the work is done on the server side and less is done on the client (application) side.

Stored routines also enable you to have libraries of functions in the database server.


CREATE
[DEFINER = { user | CURRENT_USER }]
PROCEDURE sp_name ([proc_parameter[,...]])
[characteristic ...] routine_body

CREATE
[DEFINER = { user | CURRENT_USER }]
FUNCTION sp_name ([func_parameter[,...]])
RETURNS type
[characteristic ...] routine_body

proc_parameter:
[ IN | OUT | INOUT ] param_name type

func_parameter:
param_name type

type:
Any valid MySQL data type

characteristic:
COMMENT 'string'
| LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }

routine_body:
    Valid SQL routine statement

StoreS



logoblog

Thanks for reading MYSQL stored procedure | MYSQL Function | MYSQL stored routines

Previous
« Prev Post

No comments:

Post a Comment