user3276768
user3276768

Reputation: 1436

Confusion about the term ad-hoc query

I have been reading about the term ad-hoc query and I'm quite confused about it, in particular about how they are executed. While reading a thread (What is Ad Hoc Query?), they mentioned that ad-hoc queries are written "on the fly". Does this mean that for a query to be ad-hoc it has to be written at the moment, like in a CLI or a DBMS? What about a query that I just wrote in a script for a specific purpose, is it still considered to be ad-hoc even though it is part of a script?

Thanks

Upvotes: 0

Views: 556

Answers (1)

Rick James
Rick James

Reputation: 142278

A "production" system has a lot of "canned queries". Such queries rarely change -- usually only when you "release" a new "version" of the "product".

An "Ad Hoc query" is a SELECT that you make up to look for something for which the canned queries don't help. It often comes from management asking something like "How many foobars happened last week?"

You will run that query once (or until you get the desired output), then toss it. Or you might develop it into a "canned query" for the "production" system, at which point it should no longer be called "ad hoc".

Upvotes: 1

Related Questions