zoukankan      html  css  js  c++  java
  • mysql存储过程

    创建存储过程

    1.创建一个无参数的存储过程。

    delimiter //               #mysql默认结束标志为分号,现在修改为两个斜杠。
    create procedure pro_student()
    begin
      delete from students;
    end //
    delimiter ;                #还原默认的结束标志。
    

    2.创建一个有参数的存储过程。

    delimiter //
    create procedure pro_student(in sid int)
    begin
      select * from students where id=sid;
    end //
    delimiter ;

    3.创建一个带输出参数的存储过程 。

    delimiter //
    create procedure pro_student_count(out coun int)
    begin
      select count(*) into coun from students;
    end //
    delimiter ;
    
    
    call pro_student_count(@count);
    select @count;
    
    
    #结果:2
    

      

    .调用存储过程。

    #无参数调用方式:
    call pro_student
    
    #有参数调用方式:
    call pro_student(1);
    

    4.删除一个存储过程

    drop procedure pro_student;
    

      

  • 相关阅读:
    ThinkPHP5.1 行为与钩子
    PHP 商品秒杀抢购业务流程
    MySQL 读写分离
    Redis 管道
    Redis 事务
    Redis 锁机制
    ThinkPHP 实现队列
    MySQL 存储引擎
    分布式唯一ID分配问题
    Lightscape
  • 原文地址:https://www.cnblogs.com/orna/p/8302240.html
Copyright © 2011-2022 走看看