什么是临时查询?

发布于 2024-08-26 05:27:41 字数 71 浏览 6 评论 0原文

我正在读一本关于 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 技术交流群。

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

发布评论

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

评论(11

伤痕我心 2024-09-02 05:27:41

Ad hoc 是拉丁语,意思是“为此目的”。您可以将其称为“即时”查询或“就这样”查询。这是一种 SQL 查询,您只需在需要的地方松散地键入

var newSqlQuery = "SELECT * FROM table WHERE id = " + myId;

...每次执行该行代码时,这都是一个完全不同的查询,具体取决于 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

var newSqlQuery = "SELECT * FROM table WHERE id = " + myId;

...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.

你的笑 2024-09-02 05:27:41

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

甜心 2024-09-02 05:27:41

临时查询是一种为从数据库服务器上可用的任何或多个合并表提供特定记录集而创建的查询。这些查询通常用于一次性目的,并且可能不需要合并到任何存储过程中以便将来再次运行。

临时场景:您收到对具有一组唯一变量的特定数据子集的请求。如果没有预先编写的查询可以提供必要的结果,则必须编写临时查询来生成记录集结果。

除了单次使用临时查询之外,还有存储过程;即存储在数据库接口工具内的查询。然后,这些存储过程可以在模块或宏内按顺序执行,以按需、按计划或由另一个事件触发来完成预定义的任务。

存储过程场景:每个月您都需要从同一组表和相同的变量生成一份报告(这些变量可能是特定的预定义值、计算值,例如“当前结束”)月”,或用户的输入值)。您第一次将该过程创建为临时查询。测试结果以确保准确性后,您可以选择部署此查询。然后,您可以将查询或一系列查询存储在模块或宏中,以便根据需要再次运行。

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.

Ad-hoc scenario: You receive a request for a specific subset of data with a unique set of variables. If there is no pre-written query that can provide the necessary results, you must write an Ad-hoc query to generate the recordset results.

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.

Stored Procedure scenario: Every month you need to generate a report from the same set of tables and with the same variables (these variables may be specific predefined values, computed values such as “end of current month”, or a user’s input values). You would created the procedure as an ad-hoc query the first time. After testing the results to ensure accuracy, you may chose to deploy this query. You would then store the query or series of queries in a module or macro to run again as needed.

删除会话 2024-09-02 05:27:41

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.

骄傲 2024-09-02 05:27:41

Ad-hoc 语句只是 T-SQL 语句,它有一个 Where 子句,并且该Where 子句实际上可以有一个像 :

Select * from member where member_no=285;

或变量这样的文字:

declare @mno INT=285;
Select * from member where member_no=@mno

Ad-hoc Statments are just T-SQL Statements that it has a Where Clause , and that Where clause can actualy have a literal like :

Select * from member where member_no=285;

or a variable :

declare @mno INT=285;
Select * from member where member_no=@mno
一绘本一梦想 2024-09-02 05:27:41

即席查询 -

  • 这种类型的查询是为“特定目的”而设计的,这与预定义查询相反,预定义查询在每次执行时都具有相同的输出值。
  • 执行的即席查询命令每次,但结果不同,具体取决于变量的值,
  • 并且通常属于动态编程 SQL 查询,
  • 并且是在运行时创建的。

Ad-hoc Query -

  • this type of query is designed for a "particular purpose,“ which is in contrast to a predefined query, which has the same output value on every execution.
  • An ad hoc query command executed in each time, but 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.
汐鸠 2024-09-02 05:27:41

还想补充一点,即席查询容易受到 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).

韵柒 2024-09-02 05:27:41

即席查询是那些尚未定义且不需要定期查询的查询,因此它们不包含在典型的报告或查询集中

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

胡渣熟男 2024-09-02 05:27:41

临时查询是:

  1. 预先计划的问题。
  2. 预先安排的问题。
  3. 一时兴起的问题。
  4. 不会返回任何结果的问题。

An Ad-Hoc query is:

  1. Pre-planned question.
  2. Pre-scheduled question.
  3. spur of the moment question.
  4. Question that will not return any results.
深海蓝天 2024-09-02 05:27:41

即席查询是计算机定义的类型。这意味着此查询是专门设计用于仅在需要时获取任何信息。预定义的。
请参考此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

音栖息无 2024-09-02 05:27:41

在 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.

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