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