zoukankan      html  css  js  c++  java
  • 小贝_mysql 存储过程

    存储过程

    简要:
    1、什么是存储过程
    2、使用存储过程

     

    一、存储过程

    概念类似于函数,就是把一段代码封装起来。当要行这段代码的时候,能够通过调用该存储过程来实现。在封装的语句体里面。能够用if/else,case,while等控制语句能够进行sql编程


    二、使用存储过程

    2.1、查看现有的存储过程



    2.2创建存储过程

    a、无參数的存储过程

    delimiter //

    create procedure p1()

    begin

    select count(*) from goods;

    end //

       

    调用存储过程p1()



    b、带參数的存储过程(參数用于保存执行结果)

     

    delimiter //

    create procedure p2(out a int)

    begin

    select count(*) into a from goods;

    end //

    delimiter ;

     


    调用存储过程p2


    (备注: 定义变量a来保持存储过程p2的结果。然后再显示变量a的值)

    c、带參数的存储过程(參数用于执行)

    delimiter //

    create procedure p3(in a int)

    begin

    select goods_id,goods_name,shop_price from goods where goods_id=a;

    end //

    delimiter ;

     

     

     

     

     

     


    调用存储过程p3

     

    d、带有if/else的存储过程

     

    调用

     

    e、带有while的存储过程

     

    2.3、删除存储过程

     

    总结: 在mysql中。存储过程和函数的差别

    a、名称不同

    b、存储过程没有返回值


    The quieter you become。the more you are able to hear。


  • 相关阅读:
    Quartz任务调度系统,克隆表达式
    Java故障分析基础
    SpringData JPA整理
    Mockito教程
    SpringMVC单元测试-MockMvc
    SpringBoot Actuator & SpringBoot Admin
    Swagger
    Spring @AliasFor
    java命令查询属性信息
    windows版本免安装redis, nginx, zookeeper
  • 原文地址:https://www.cnblogs.com/yfceshi/p/6890665.html
Copyright © 2011-2022 走看看