为什么“非”?在“执行非查询”中?

发布于 2024-09-01 04:35:40 字数 190 浏览 5 评论 0原文

我知道这不是一个有用的问题,但我忍不住被它困扰。

所以,
为什么调用所述方法(在 *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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾挽 2024-09-08 04:35:40

从语义上讲,查询是您执行以返回数据的操作。您正在“查询”数据库以查找 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.

夜吻♂芭芘 2024-09-08 04:35:40

如果它们是 INSERT、DELETE、CREATE TABLE 等,则不是。

Not if they are INSERTs, DELETEs, CREATE TABLEs, etc.

梦行七里 2024-09-08 04:35:40

我认为这是一个查询,要求数据库返回记录。更改数据/数据库的操作不是查询。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文