In Oracle, we can write this to generate a single row using a SELECT
statement.
SELECT 1 AS x FROM dual
What is Teradata's equivalent?
In Oracle, we can write this to generate a single row using a SELECT
statement.
SELECT 1 AS x FROM dual
What is Teradata's equivalent?
Copyright © 2021 Jogjafile Inc.
Generally, no such table is needed
In most cases, no table is really needed in the Teradata database. The following is valid SQL (just like in H2, PostgreSQL, Redshift, SQL Server, SQLite, Sybase ASE, Sybase SQL Anywhere, Vertica)
Exceptions
However, there is an exception, when a set operation is desireable. E.g. this is invalid in Teradata:
Yielding this error:
But since the
FROM
clause is generally optional, it's very easy to emulate aDUAL
table as follows:Compatibility
In case compatibility needs to be achieved with Oracle etc, it is easy to create a view that behaves like Oracle's dual:
Notice that
DUAL
is a keyword in Teradata, thus the view needs to be quoted.Other dialects
In case anyone is interested, the jOOQ user manual lists various ways of emulating
DUAL
(if it's required) in 30+ SQL dialects.