Dummy tables for SQL in Oracle, MS SQL and DB2
Once in a while, you will come across scenarios where you would like to run a pre-defined function but not against a table. For example, you would like to know the date or perform some computations, but what if I don't want to use a user-defined table. Here are some ways to achieve this:
Oracle
You can use the dual table to achieve this. For ex:
SELECT sysdate from dual;
will return the current time.
You can find more info about DUAL table from Oracle's best resource (IMO), AskTom:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1562813956388
MS SQL
Just ignore the FROM clause ie:
SELECT getdate()
DB2
Use the SYSIBM.SYSDUMMY1
table. For ex:
select user, current
timestamp from sysibm.sysdummy1
For more info:
http://www-1.ibm.com/support/docview.wss?uid=swg21009013