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;
    

      

  • 相关阅读:
    *args, **kwargs
    python format函数
    python自省
    生成器与迭代器
    python面试题
    xpath和gzip
    python正则表达式
    cookie
    random
    杭电1710 (已知二叉树前中序 求后序)
  • 原文地址:https://www.cnblogs.com/orna/p/8302240.html
Copyright © 2011-2022 走看看