什么是临时查询?
我正在读一本关于 SQL 的书。那本书中有一个术语“Ad Hoc Query”,我不明白。
到底什么是即席查询?
I'm reading a book about SQL. In that book there's the term Ad Hoc Query, which I don't understand.
What exactly is an ad hoc query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
Ad hoc 是拉丁语,意思是“为此目的”。您可以将其称为“即时”查询或“就这样”查询。这是一种 SQL 查询,您只需在需要的地方松散地键入
...每次执行该行代码时,这都是一个完全不同的查询,具体取决于
myId
的值。与即席查询相反的是预定义查询,例如存储过程,您在其中创建了一个查询来实现从该表中进行选择的整个通用目的(例如),并将 ID 作为变量传递。Ad hoc is latin for "for this purpose". You might call it an "on the fly" query, or a "just so" query. It's the kind of SQL query you just loosely type out where you need it
...which is an entirely different query each time that line of code is executed, depending on the value of
myId
. The opposite of an ad hoc query is a predefined query such as a Stored Procedure, where you have created a single query for the entire generalized purpose of selecting from that table (say), and pass the ID as a variable.Ad-Hoc 查询是在发出查询之前无法确定的查询。它是为了在需要时获取信息而创建的,它由动态构建的 SQL 组成,该 SQL 通常由桌面驻留查询工具构建。
检查:http:// /www.learn.geekinterview.com/data-warehouse/dw-basics/what-is-an-ad-hoc-query.html
An Ad-Hoc Query is a query that cannot be determined prior to the moment the query is issued. It is created in order to get information when need arises and it consists of dynamically constructed SQL which is usually constructed by desktop-resident query tools.
Check: http://www.learn.geekinterview.com/data-warehouse/dw-basics/what-is-an-ad-hoc-query.html
临时查询是一种为从数据库服务器上可用的任何或多个合并表提供特定记录集而创建的查询。这些查询通常用于一次性目的,并且可能不需要合并到任何存储过程中以便将来再次运行。
除了单次使用临时查询之外,还有存储过程;即存储在数据库接口工具内的查询。然后,这些存储过程可以在模块或宏内按顺序执行,以按需、按计划或由另一个事件触发来完成预定义的任务。
An Ad-hoc query is one created to provide a specific recordset from any or multiple merged tables available on the DB server. These queries usually serve a single-use purpose, and may not be necessary to incorporate into any stored procedure to run again in the future.
Beyond a single use Ad-hoc query are stored procedures; i.e. queries which are stored within the DB interface tool. These stored procedures can then be executed in sequence within a module or macro to accomplish a predefined task either on demand, on a schedule, or triggered by another event.
Ad-Hoc 查询是在发出查询之前无法确定的查询。它是为了在需要时获取信息而创建的,它由动态构建的 SQL 组成,该 SQL 通常由桌面驻留查询工具构建。
即席查询并不驻留在计算机或数据库管理器中,而是根据数据用户的需要动态创建。
在 SQL 中,即席查询是松散类型的命令/查询,其值取决于某些变量。每次执行该命令时,结果都会不同,具体取决于变量的值。它无法预先确定,通常属于动态编程 SQL 查询。即席查询的生命周期很短,是在运行时创建的。
An Ad-Hoc Query is a query that cannot be determined prior to the moment the query is issued. It is created in order to get information when need arises and it consists of dynamically constructed SQL which is usually constructed by desktop-resident query tools.
An ad hoc query does not reside in the computer or the database manager but is dynamically created depending on the needs of the data user.
In SQL, an ad hoc query is a loosely typed command/query whose value depends upon some variable. Each time the command is executed, the result is different, depending on the value of the variable. It cannot be predetermined and usually comes under dynamic programming SQL query. An ad hoc query is short lived and is created at runtime.
Ad-hoc 语句只是 T-SQL 语句,它有一个 Where 子句,并且该Where 子句实际上可以有一个像 :
或变量这样的文字:
Ad-hoc Statments are just T-SQL Statements that it has a Where Clause , and that Where clause can actualy have a literal like :
or a variable :
即席查询 -
Ad-hoc Query -
还想补充一点,即席查询容易受到 SQL 注入攻击。我们应该尽量避免使用它,而使用参数化 SQL(像 Java 中的PreparedStatement) )。
Also want to add that ad hoc query is vulnerable to SQL injection attacks. We should try to avoid using it and use parameterized SQLs instead (like PreparedStatement in Java).
即席查询是那些尚未定义且不需要定期查询的查询,因此它们不包含在典型的报告或查询集中
Ad hoc queries are those that are not already defined that are not needed on a regular basis, so they're not included in the typical set of reports or queries
临时查询是:
An Ad-Hoc query is:
即席查询是计算机定义的类型。这意味着此查询是专门设计用于仅在需要时获取任何信息。预定义的。
请参考此https://www.youtube.com/watch?v=0c8JEKmVXhU
Ad hoc query is type of computer definition. Which means this query is specially design to obtain any information when it is only needed. Predefined.
refer this https://www.youtube.com/watch?v=0c8JEKmVXhU
在 Sql Server 中,“Ad Hoc Query”也用于 Ad Hoc 分布式查询。这些是通过 OpenRowset 或 OpenDatasource 在其他服务器上进行的即席查询。仅在配置后才允许临时分布式查询。这是一个服务器配置选项。
In Sql Server "Ad Hoc Query" is also used for Ad Hoc Distributed Queries. These are ad hoc queries on an other server via OpenRowset or OpenDatasource. Ad Hoc Distributed Queries are only allowed after configuring so. This is a Server configuration option.