| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Counting propositions
x wrote:
> "Laconic2" <laconic2_at_comcast.net> wrote:
> > At compile time. > But when is compile time ? :-)
Logically equivalent to when the query starts execution - in embedded SQL, at the time of the OPEN of a cursor.
If the system has no pre-compilation phase, then that's a given - all statements are handled that way.
If, like IBM DB2, you have an elaborate pre-compilation phase, then an automatic recompile would occur if the table had changed enough to invalidate the previous query plan - and adding a column would surely do that!
If something changes between the time of PREPARE and OPEN, then either the OPEN will fail or the query will be recompiled - so that doesn't matter either.
As a matter of good practice (and following relational theory rather than SQL practice), the answer to the query should be the same as:
SELECT COUNT(*) AS nr FROM <relvar>
because the <relvar> should have either a primary key or one or more candidate keys that enforce uniqueness without needing the DISTINCT.
-- Jonathan Leffler #include <disclaimer.h> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/Received on Mon Jun 14 2004 - 10:48:33 CDT
![]() |
![]() |