DUAL table is a special one-row, one-column table automatically created by Oracle Database as part of the data dictionary. It is present by default in Oracle installations and has also been adopted in various forms by other database systems.
Structure
In Oracle Database, the DUAL table has a single column named DUMMY, defined as VARCHAR2(1), containing a single row with the value 'X'. It resides in the schema of the user SYS but is accessible by the name DUAL to all users.
Purpose
Oracle's SQL syntax requires a FROM clause in every SELECT statement. The DUAL table exists to satisfy this syntactic requirement when a query does not need data from any actual table — such as when computing a constant expression, calling a function, or selecting a pseudocolumn (e.g., SYSDATE or USER). Because DUAL contains exactly one row, the constant or expression result is returned exactly once.
Example Usage
SELECT 1 + 1 FROM dual; -- Returns: 2
SELECT USER FROM dual; -- Returns the current username
SELECT SYSDATE FROM dual; -- Returns the current date and time
SELECT * FROM dual; -- Returns: 'X'
History
The DUAL table was created by Charles Weiss, an Oracle developer, as an underlying object in the Oracle Data Dictionary. It was originally designed for use inside a view that performed a JOIN to produce two rows per row in another table, enabling GROUP BY summaries of data and index extent storage. The name "DUAL" was chosen to reflect the process of creating a pair of rows from just one.
Optimization
Beginning with Oracle Database 10g Release 1, Oracle no longer performs physical or logical I/O on the DUAL table when computing an expression that does not reference the DUMMY column. This optimization is referred to as FAST DUAL in the execution plan. If the DUMMY column is explicitly selected, the optimization does not apply and logical I/O occurs.
Usage in Other Database Systems
Several other databases do not require a dummy table for such queries, as they allow the FROM clause to be omitted entirely. However, some systems provide their own equivalents:
- ClickHouse: Provides
system.one, a one-row table with a singleUInt8column nameddummywith value0. - Firebird: Uses
RDB$DATABASE, a one-row system table with similar functionality. - IBM Db2: Has
sysibm.sysdummy1and resolvesDUALthrough Oracle compatibility mode. - Informix: Provides
sysmaster:"informix".sysdual(version 11.50 and later). A public synonymdualcan be created for convenience. - MySQL: Allows
DUALto be specified as a table inSELECTqueries (e.g.,SELECT NOW() FROM dual), though it is not required. - PostgreSQL: Does not require a dummy table, but a
DUALview can be created to ease migration from Oracle. - SAP HANA: Provides a table called
DUMMYwith equivalent functionality. - Snowflake: Supports
DUAL(referenced in documentation, though not explicitly documented as a system object). - SQLite: Does not require a dummy table, but a
DUALview can be manually created. - Vertica: Officially documents support for a
DUALtable.