为什么“非”?在“执行非查询”中?
我知道这不是一个有用的问题,但我忍不住被它困扰。
所以,
为什么调用所述方法(在 *Command
类中)
ExecuteNonQuery 而不是 ExecuteQuery?
我们向数据库抛出的那些 SQL 语句不是查询吗?
I know this is not a hell of an useful question but I can't help being bugged by it.
So,
Why said method (in *Command
classes) is called
ExecuteNonQuery instead of ExecuteQuery?
Aren't those SQL statements we throw at DBs, queries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从语义上讲,查询是您执行以返回数据的操作。您正在“查询”数据库以查找 Y 中的所有 X。
如果您不期望返回结果,那么与其说它是查询,不如说它是语句或命令。
Semantically, a query is something you execute to return data. You're 'querying' the database to find all the X in the Y.
If you're not expecting back results, it's not so much a query as it is a statement or command.
如果它们是 INSERT、DELETE、CREATE TABLE 等,则不是。
Not if they are INSERTs, DELETEs, CREATE TABLEs, etc.
我认为这是一个查询,要求数据库返回记录。更改数据/数据库的操作不是查询。
I would think of it as a query is asking the database for records back. Actions that alter the data/database would not be a query.