博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MYSQL动态查询拼接的表名的SQL脚本实现(MYSQL动态执行SQL脚本)
阅读量:4614 次
发布时间:2019-06-09

本文共 476 字,大约阅读时间需要 1 分钟。

 

可以使用MYSQL的预处理逻辑:https://dev.mysql.com/doc/refman/8.0/en/sql-syntax-prepared-statements.html   例如:

 

prepare stmt from 'select * from student where sage = ?'; set @a=20; execute stmt using @a ;

  

每一次执行完EXECUTE时,养成好习惯,须执行DEALLOCATE PREPARE … 语句,这样可以释放执行中使用的所有数据库资源(如游标)。不仅如此,如果一个session的预处理语句过多,可能会达到max_prepared_stmt_count的上限值。

 

跟MYSQL类似:使用完毕需要关闭PrepareStament 。参见:https://dev.mysql.com/doc/refman/8.0/en/deallocate-prepare.html

转载于:https://www.cnblogs.com/leodaxin/p/10340651.html

你可能感兴趣的文章
osip及eXosip的编译方法
查看>>
Hibernate composite key
查看>>
[CF Round #294 div2] D. A and B and Interesting Substrings 【Map】
查看>>
keepalived+nginx安装配置
查看>>
我的2015---找寻真实的自己
查看>>
android编译遇到问题修改
查看>>
解决Ubuntu18.04.2远程桌面Xrdp登录蓝屏问题
查看>>
python_封装redis_hash方法
查看>>
Git的安装和使用教程详解
查看>>
lsof命令详解
查看>>
常用模块,异常处理
查看>>
父窗口与子窗口之间的传值
查看>>
eclipse 找不到 tomcat 的解决方案
查看>>
HDU 1890--Robotic Sort(Splay Tree)
查看>>
connection string for Excel/Access 2010
查看>>
【转】【Python】Python中的__init__.py与模块导入(from import 找不到模块的问题)
查看>>
学习wavenet_vocoder之环境配置
查看>>
常用Maven命令
查看>>
Docker启动mysql的坑2
查看>>
j2ee爬坑行之二 servlet
查看>>