1.Stored programs include these objects:
a).Stored routines, that is, stored procedures and functions. A stored procedure is invoked using the CALL statement. A procedure does not have a return value but can modify its parameters for later inspection by the caller. It can also generate result sets to be returned to the client program. A stored function is used much like a built-in function. you invoke it in an expression and it returns a value during expression evaluation.
b).Triggers. A trigger is a named database object that is associated with a table and that is activated when a particular event occurs for the table, such as an insert or update.
c).Events. An event is a task that the server runs according to schedule.
2.Defining Stored Programs
Each stored program contains a body that consists of an SQL statement. This statement may be a compound statement made up of several statements separated by semicolon (;) characters.
CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END;
Stored routines require the proc table in the mysql database.
mysql stored procedure
1.创建
delimiter //
create procedure calcal(actId int)
begin
#do something
end;
//
delimiter ;
2.查看
方法一:
select `name` from mysql.proc where db = 'your_db_name' and `type` = 'PROCEDURE'
方法二:
show procedure status;
3.删除
drop procedure db_name.sp_name;
分享到:
相关推荐
Part III: Using MySQL Stored Programs in Applications Chapter 12. Using MySQL Stored Programs in Applications Section 12.1. The Pros and Cons of Stored Programs in Modern Applications Section ...
《Chapter 23 Stored Programs and Views.pdf》介绍了存储过程、函数、触发器和视图,这些是数据库中的高级特性,用于实现复杂业务逻辑和数据处理。 最后,《INFORMATION_SCHEMA Index.pdf》是关于INFORMATION_...
- **新功能**:MySQL 5.7 中的 Performance Schema 包含了新的表和视图,例如针对 Metadata Locking 的跟踪、Stage Tracking 的监控等,同时增强了对 Stored Programs 的监控能力。 - **其他改进**:新增了 `SHOW ...
- **Views and Stored Programs**:视图和存储程序,介绍如何创建和使用视图以及存储过程。 - **MySQL Installer**:MySQL安装程序,提供了安装MySQL的各种方法。 - **MySQL Enterprise Backup**:企业备份工具,...
To ensure efficient and secure data storage and retrieval, the MySQL database would be optimized using indexing, normalization, and stored procedures. Security aspects such as user authentication, ...
- **存储程序监控(Stored Programs)**:包含了对存储过程、存储函数、事件调度器和表触发器的监控。在`setup_objects`表中,新增了对这些对象的探测器。 **2. Sys Schema** Sys Schema是MySQL 5.7引入的一个新的...
It suppots such database as Oralce,MS SQLServer,MySQL,Access,SQLAnywhere and Sybase. Through the BDB you can quickly build up a database model and do two-way synchronization entities with the ...
It suppots such database as Oralce,MS SQLServer,MySQL,Access,SQLAnywhere and Sybase. Through the BDB you can quickly build up a database model and do two-way synchronization entities with the ...
Chapter 22 Drawing Marker Positions Using Data Stored in a Database 355 22.1 PROBLEM DESCRIPTION 355 22.1.1 Preliminary Work on the Data 355 22.1.2 MongoDB Version with Commented Source Code 358 ...