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

    1、存储过程是什么?

      sql集合 

    2、为什么要用存储过程?

      数据库操作快(普通sql执行一次,编译一次;存储过程,编译一次,永久可以执行)

      数据库操作与程序的耦合性低;(数据库操作需要修改,只修改存储过程就行,不用修改程序)

      模块化,代码复用性好

    3、如何使用存储过程?

      java程序调用存储过程(https://zhidao.baidu.com/question/266022580419344205.html)

      String sql = "{call test_procedure(?)}";

      CallableStatement cs = conn.prepareCall(sql);

    4、存储过程的定义及调用(无参)

    drop procedure if exists sp_name;

    delimiter //  #定界符将默认的分号语句结束符改为//

    create procedure sp_name()

    begin

    select * from table_name;

    end //

    delimiter ;  #将sql语句结束符还原为分号;

    call sp_name();  #调用存储过程

    5、存储过程(有参 in | out | inout) 

    IN 

    #存储过程不能重载,所以删除语句只包含存储过程名称。

    #select * into 也是一种给变量赋值的方式

    OUT

    INOUT

  • 相关阅读:
    R的农场 chebnear
    math
    求平面内最近点对
    字符加密 cipher
    CF448C Painting Fence
    CF264B Good Sequences
    洛谷3166 数三角形
    [NOIP2013] 华容道
    [NOIP2013] 货车运输
    [NOIP2013] 积木大赛
  • 原文地址:https://www.cnblogs.com/hblthink/p/8666730.html
Copyright © 2011-2022 走看看