预编译方面的声明与准备好的声明 [英] Statement vs Prepared Statement in terms of Precompilation

查看:95
本文介绍了预编译方面的声明与准备好的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解使用Statement和PreparedStatement之间的主要区别(PreparedStatements允许传入参数).但是我读到了两者之间的细微差别-即PreparedStatement比通用语句要快,因为PreparedStatement SQL是预编译的.

I understand the main difference between using Statement and PreparedStatement (PreparedStatements allow passing in parameters). But I read about a subtle difference between the two - namely that PreparedStatements can be quicker than generic Statements, because PreparedStatement SQL is precompiled.

预编译到底是什么意思,为什么会有所作为?

What exactly does being precompiled mean, and why does it make a difference?

推荐答案

一条准备好的语句执行以下检查:

A prepared statement performs the following checks:

  • 确保表和列存在
  • 确保参数类型匹配其列
  • 解析SQL以确保语法正确
  • 编译并缓存已编译的SQL,因此无需重复这些步骤即可重新执行它

这篇关于预编译方面的声明与准备好的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆