当前位置: 首页 > article >正文

Real SQL Programming

目录

SQL in Real Programs

Options

Stored Procedures

Advantages of Stored Procedures

Parameters in PSM


SQL in Real Programs

  • We have seen only how SQL is used at the generic query interface --- an environment where we sit at a terminal and ask queries of a database.

  • Reality is almost always different:

conventional programs interacting with SQL.

(我们只是看见了SQL是如何在常规的查询接口中的使用,也就是直接通过终端 对数据库进行交互,但实际上通常是常规程序与SQL语言的交互)

Options

  • Code in a specialized language is stored in the database itself (e.g.PSM, PL/SQL).
  • SQL statements are embedded in a host language (e.g., C).
  • Connection tools are used to allow a conventional language to access a database (e.g., CLI, JDBC, PHP/DB).

(常规程序与SQL语言的交互模式: 数据库储存代码、SQL内嵌、连接工具)

Stored Procedures

  • PSM, or “persistent stored modules, ” allows us to store procedures as database schema elements.(持久储存模块允许我们将储存模式作为数据库模式元素)

  • PSM = a mixture of conventional statements (if, while, etc.) and SQL.

  • Lets us do things we cannot do in SQL alone.

数据库中的储存过程和函数的区别在于,函数可以直接通过函数名的引用得到函数值,但是储存过程不行

Advantages of Stored Procedures

  • Share Application Logic(共享应用逻辑)
  • Shield Database Schema Details(屏蔽数据库细节)
  • Provide Security Mechanisms(提供安全机制 )
  • Improve Performance(提升性能)
  • Reduce Network Traffic(减少网络流量)

Parameters in PSM

Unlike the usual name-type pairs in languages like C, PSM uses mode- name-type triples, where the mode can be:

  • IN = procedure uses value, does not change value.(传入参数,只能调用不能修改)

  • OUT = procedure changes, does not use.(传出参数,可以在储存过程被修改)

  • INOUT = both

想得到储存过程的返回值,虽然不能直接通过调用储存过程名字,但是可以调用OUT参数

http://www.lryc.cn/news/2394146.html

相关文章:

  • Sentinel限流熔断机制实战
  • Java 数据处理 - 数值转不同进制的字符串(数值转十进制字符串、数值转二进制字符串、数值转八进制字符串、数值转十六进制字符串)
  • 79. 单词搜索-极致优化,可行性剪枝和顺序剪枝
  • ICDMC 2025:创新媒体模式,迎接数字时代的挑战
  • 深入解析C#多态性:基类引用、虚方法与覆写机制
  • SoftThinking:让模型学会模糊思考,同时提升准确性和推理速度!!
  • C++中 newdelete 与 mallocfree 的异同详解
  • 晨控CK-UR08与欧姆龙PLC配置Ethernet/IP通讯连接操作手册
  • STM32入门教程——LED闪烁LED流水灯蜂鸣器
  • 鸿蒙OSUniApp 实现的数据可视化图表组件#三方框架 #Uniapp
  • Tornado WebSocket实时聊天实例
  • HarmonyOS鸿蒙与React Native的融合开发模式以及能否增加对性能优化的具体案例
  • 化学分析原理。
  • 开源即战力!从科研到商用:Hello Robot 移动操作机器人Stretch 3多模态传感融合(RGB-D/激光/力矩)控制方案
  • 元胞自动机(Cellular Automata, CA)
  • 智能手表单元测试报告(Unit Test Report)
  • 微深节能 码头装卸船机定位与控制系统 格雷母线
  • 基于matlab遗传算法和模拟退火算法求解三维装箱优化问题
  • 在Spring Boot中集成Redis进行缓存
  • Python实现P-PSO优化算法优化循环神经网络LSTM分类模型项目实战
  • OSG编译wasm尝试
  • Scratch节日 | 龙舟比赛 | 端午节
  • Ubuntu搭建DNS服务器
  • electron开发百度桌面应用demo及如何打包应用
  • 关于用Cloudflare的Zero Trust实现绕过备案访问国内站点说明
  • 2025年DDoS混合CC攻击防御全攻略:构建智能弹性防护体系
  • 方正字库助力华为,赋能鸿蒙电脑打造全场景字体解决方案
  • STM32 串口通信①:USART 全面理解 + 代码详解
  • 【Java Web】速通CSS
  • List 源码翻译