zoukankan      html  css  js  c++  java
  • 数据库高级应用之存储过程

    存储过程作用:
    存储在数据库服务端供客户端使用的调用执行的SQL语句就是存储过程

    格式:
    sql 语句:
        create procedure p_student
            @dept char(20)
            as
                select sname,cname,grade
                    from student s join score sc on s.sno = sc.sno join course c on c.cno = sc.cno
                    where sdept = @dept

    MySQL语句:
    create procedure pr_add
    (
       a int,
       b int
    )
    begin
       declare c int;
       if a is null then
          set a = 0;
       end if;
       if b is null then
          set b = 0;
       end if;
       set c = a + b;
       select c as sum;
       
    end;


    执行存储过程:

    单个或者知道序列顺序的使用:
    Exec p_student '计算机系'

    多个参数的使用:
    Exec p_student @sdept = '计算机系',@cname = '数学'

  • 相关阅读:
    CSS学习1
    三个和尚没水喝阅读笔记
    Javascript学习1

    mv 批量
    emacs 大小写转换
    too many open files
    成都定房
    有关重定向
    postgresql 数据库
  • 原文地址:https://www.cnblogs.com/Stakes-ds/p/8454469.html
Copyright © 2011-2022 走看看