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-创建函数,存储过程以及视图的更多相关文章

  1. Mysql创建函数出错

    目前在项目中,执行创建mysql的函数出错, mysql 创建函数出错信息如下: Error Code: 1227. Access denied; you need (at least one of) ...

  2. MySQL创建函数报“ERROR 1418 ”错误,不能创建函数

    MySQL创建函数报ERROR 1418错误,不能创建函数,根据官方提示是说,不能创建函数可能是一个安全设置方面的配置或功能未开启原因,下面我们一起来看.   错误 ERROR 1418 (HY000 ...

  3. mysql 创建函数ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_f

    mysql 创建函数的时候 报错 ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL D ...

  4. MySQL 创建函数失败提示1418

    MySQL 创建函数失败提示1418 在创建函数时,往往会遇到创建函数失败的情形,除去书写的创建函数的sql语句本身语法错误之外,还会碰到一个错误就是, 1418:This function has ...

  5. mysql 创建函数set global log_bin_trust_function_creators=TRUE;

    <pre name="code" class="html">set global log_bin_trust_function_creators=T ...

  6. MySQL 创建函数(Function)

    目标 怎么样MySQL创建数据库功能(Function) 语法 CREATE FUNCTION func_name ( [func_parameter] ) //括号是必须的,參数是可选的 RETUR ...

  7. MySql创建一个存储过程

    MySQL 存储过程是从 MySQL 5.0 新功能.存储过程的长处有一箩筐.只是最基本的还是运行效率和SQL 代码封装. 特别是 SQL 代码封装功能,假设没有存储过程,在外部程序訪问数据库时(比如 ...

  8. MySql创建函数与过程,触发器, shell脚本与sql的相互调用。

    一:函数 1:创建数据库和表deptartment, mysql> use DBSC; Database changed mysql), ), )); Query OK, rows affect ...

  9. [置顶] MySQL -- 创建函数(Function

    目标 如何在MySQL数据库中创建函数(Function) 语法 CREATE FUNCTION func_name ( [func_parameter] ) //括号是必须的,参数是可选的 RETU ...

  10. mysql 创建函数

    <pre name="code" class="html">root 用户创建函数: delimiter $$ CREATE FUNCTION `l ...

随机推荐

  1. [Redux] Avoiding Object Mutations with Object.assign() and ...spread

    Learn how to use Object.assign() and the spread operator proposed for ES7 to avoid mutating objects. ...

  2. Android(java)学习笔记252:ContentProvider使用之内容观察者01

    1. 内容观察者 不属于四大组件,只是内容提供者ContentProvider对应的小功能. 如果发现数据库内容变化了,就会立刻观察到. 下面是逻辑图:       当A应用中银行内部的数据发生变化的 ...

  3. Topcoder SRM 648 (div.2)

    第一次做TC全部通过,截图纪念一下. 终于蓝了一次,也是TC上第一次变成蓝名,下次就要做Div.1了,希望div1不要挂零..._(:зゝ∠)_ A. KitayutaMart2 万年不变的水题. # ...

  4. 【网络流#8】POJ 3469 Dual Core CPU 最小割【ISAP模板】 - 《挑战程序设计竞赛》例题

    [题意]有n个程序,分别在两个内核中运行,程序i在内核A上运行代价为ai,在内核B上运行的代价为bi,现在有程序间数据交换,如果两个程序在同一核上运行,则不产生额外代价,在不同核上运行则产生Cij的额 ...

  5. python运行时间计算之timeit

    timeit.timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000) stmt:statement ...

  6. require(),include(),require_once()和include_once()之间的区别

    引用文件的方法有两种:require 及 include. require 的使用方法如 require("file.php"); .这个函数通常放在 PHP 程序的最前面,PHP ...

  7. libthrift0.9.0解析(二)之TSimpleServer

    TSimpleServer简单实现Tserver,代码如下. /** * Simple singlethreaded server for testing. * */ public class TSi ...

  8. 关于cocopads 不能正确安装的问题

    通过几个网页 我搜到 看着几个网页就够了 绝对可以实现的 http://code4app.com/article/cocoapods-install-usage http://www.cnblogs. ...

  9. PHP 函数的引用传递

    $a = "nowamagic";$b =& $a;echo $b.$a; 这意味着 $a 和 $b 指向了同一个变量.同一个变量内容有不同的变量名,引用就是这么个回事. ...

  10. Java下载Servlet Demo

    request.setCharacterEncoding("utf-8"); String name=request.getParameter("name"); ...