mysql-创建函数,存储过程以及视图
2013-05-28 20:08
856 查看
1.创建函数 mysql>delimiter // mysql>create function 函数名(参数1 参数1类型,...) returns 返回类型 >begin >return 返回值; >end >// mysql>select 函数名(参数1, 参数2, 。。。); >//
创建存数过程 建表 create table user( id mediumint(8) unsigned not null auto_increment, name char(15) not null default "", pass char(32) not null default "", note text not null, primary key (id) )engine=Innodb charset=utf8; insert into user(nsme, pass, note) values('sss','123', 'ok'); 存储过程 mysql>delimiter // mysql>create procedure proc_name (in parameter integer) mysql>begin mysql>if parameter=0 then mysql>select * from user order by id asc; mysql>else mysql>select * from user order by id desc; mysql>end if; mysql>end; mysql>// 执行: mysql>call proc_name(0); mysql>// 执行结果:
创建视图 create view my_view as select pass from user; 调用视图:select v.pass from my_view v; 执行结果:
注:
1.show procedure status; 显示数据库中所有存储的存储过程基本信息,包括所属数据库,存储过程名称,创建时间等
2.show create procedure sp_name 显示某一个存储过程的详细信息
相关文章推荐
- mysql-创建函数,存储过程以及视图
- mysql-创建函数,存储过程以及视图
- mysql中的存储过程、触发器、视图是如何创建的,以及PHP中是如何调用的
- mysql中的存储过程、触发器、视图是如何创建的,以及PHP中是如何调用的
- mysql查看所有存储过程,函数,视图,触发器,表
- mysql 查询表,视图,触发器,函数,存储过程
- mysql 导入导出数据库以及函数、存储过程的介绍
- SQLServer2005里怎样对使用with encryption选项创建的解密存储过程、解密函数、触发器、视图
- 查看MySQL所有存储过程、函数、视图、触发器及表
- MySQL存储过程和自定义函数、Navicat、创建存储过程和函数、调用存储过程和函数、三种方式、In和Out类型参数、
- 37、MySQL-创建存储过程和函数
- mysql创建自定义函数与存储过程
- MySQL存储过程和自定义函数、Navicat for mysql、创建存储过程和函数、调用存储过程和函数的区别
- 修改MySql的存储过程、函数、事件、触发器、视图的 DEFINER
- Mysql创建存储过程和函数基础总结
- mysql查询存储过程和函数、视图、触发器
- mysql基础三(视图、触发器、函数、存储过程、事务、防注入)
- mysql 视图、存储过程和函数
- mysql查看所有存储过程,函数,视图,触发器,表
- mysql查看所有存储过程,函数,视图,触发器,表