`
linvar
  • 浏览: 257627 次
  • 性别: Icon_minigender_1
  • 来自: 未定
社区版块
存档分类
最新评论

Mysql Stored Programs

阅读更多

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;
分享到:
评论

相关推荐

    MySql存储过程编程.chm

    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 ...

    MySQL5.7官方文档翻译版

    《Chapter 23 Stored Programs and Views.pdf》介绍了存储过程、函数、触发器和视图,这些是数据库中的高级特性,用于实现复杂业务逻辑和数据处理。 最后,《INFORMATION_SCHEMA Index.pdf》是关于INFORMATION_...

    MySQL-5.7新增功能全揭秘中文版

    - **新功能**:MySQL 5.7 中的 Performance Schema 包含了新的表和视图,例如针对 Metadata Locking 的跟踪、Stage Tracking 的监控等,同时增强了对 Stored Programs 的监控能力。 - **其他改进**:新增了 `SHOW ...

    mysql_refman-5.6-en.a4.pdf

    - **Views and Stored Programs**:视图和存储程序,介绍如何创建和使用视图以及存储过程。 - **MySQL Installer**:MySQL安装程序,提供了安装MySQL的各种方法。 - **MySQL Enterprise Backup**:企业备份工具,...

    基于ssm+mysql的超市管理系统源码数据库论文.doc

    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, ...

    MySQL5.7中 performance和sys schema中的监控参数解释(推荐)

    - **存储程序监控(Stored Programs)**:包含了对存储过程、存储函数、事件调度器和表触发器的监控。在`setup_objects`表中,新增了对这些对象的探测器。 **2. Sys Schema** Sys Schema是MySQL 5.7引入的一个新的...

    Database design & Database deployment software BDB 2007 Professional V2.3

    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 ...

    Database design & Database deployment software BDB 2007 Developer V2.3

    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 ...

    Python for Bioinformatics 第二版,最新版

    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 ...

Global site tag (gtag.js) - Google Analytics