Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SELECT SQL expression without FROM clause

Gerald Venzl-OracleApr 27 2020 — edited May 7 2020

To select values from SQL expressions, a FROM clause is not strictly required as the expression is not selected from that table anyway.

For example:

SELECT sysdate;

SELECT 1+2;

SELECT my_fuction();

Oracle uses the FROM dual construct as a workaround for that scenario where dual is a dummy one-column, one-row table, translating the above to:

SELECT sysdate FROM dual;

SELECT 1_2 FROM dual;

SELECT my_function() FROM DUAL;

Although the SQL standard doesn't allow a SELECT statement without a FROM clause, pretty much every other database does support the construct of selecting and expression without a FROM clause. Especially for beginners, users coming from other databases and quick tests, not having to know of and type FROM dual all the time aids user-friendliness.

Comments

Post Details

Added on Apr 27 2020
3 comments
7,682 views