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

  • 相关阅读:
    C#中yield return用法分析
    SQL表连接查询(inner join(join)、full join、left join、right join、cross join)
    SQL Server 数据类型转换函数
    linq查询结果指定列的两种方式
    html2cavans
    ORM
    Node.js Web 模块
    Node.js GET/POST请求
    Node.js 文件系统
    装逼利器函数注释
  • 原文地址:https://www.cnblogs.com/hblthink/p/8666730.html
Copyright © 2011-2022 走看看