Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Does "WHERE 0=1" require a full table scan?
Hi,
a simple question: For a query like "SELECT * FROM table WHERE 0=1", does Oracle do a full table scan, or does it optimize the query away and return nothing without accessing the table?
The background for this question is, I'm writing a C++ function that takes a column name and a list of strings and creates a WHERE clause to search for these strings, like "column IN ('string 1','string 2',...). In case of an empty list I want to create a WHERE clause that matches nothing, and I'm pondering whether "WHERE 0=1" or "WHERE column!=column" would be better.
Thanks for your help
Wolfram Roesler
Received on Fri Jan 30 2004 - 05:13:37 CST