Home >Database >Mysql Tutorial >Does Oracle Allow SELECT Queries Without a FROM Clause, and If So, What's the Recommended Approach?
Can Oracle Execute SELECT Queries Without a FROM Clause?
Oracle, unlike SQL Server, does not support SELECT queries without a FROM clause. As a workaround, it is common practice to use the dual table for such operations, as seen in the example below:
Select 1,2+3, 'my dummy string' FROM DUAL
Is This Practice Recommended?
Using the dual table for fromless SELECT queries is considered good practice in Oracle. Dual is an in-memory table that employs a fast access path (FAST DUAL) when DUMMY is not selected, eliminating I/O operations.
Originally, dual consisted of two records and was used as a dummy recordset for joining. Today, it contains only one record. However, it allows for the generation of an arbitrary number of rows using the CONNECT BY clause:
SELECT level FROM dual CONNECT BY level <= 100
Other Platforms
It's worth noting that MySQL also supports the use of dual and fromless SELECT syntax.
The above is the detailed content of Does Oracle Allow SELECT Queries Without a FROM Clause, and If So, What's the Recommended Approach?. For more information, please follow other related articles on the PHP Chinese website!