Select from dual in SQL / Hive

Raymond Tang Raymond Tang 4925 2.18 index 5/28/2019

In Oracle database, you can select from dual table if you only want to return a one row result set. In many other databases, the query engine supports select directly from constant values without specifying a table name.

In Hive, there is no system table named Dual. However you can directly created table name Dual.

Alternatively, you can also directly query from constant values or built-in functions without specifying a table name.

Code snippet

CREATE TABLE DUAL(Dummy VARCHAR(1));
INSERT INTO DUAL VALUES ('X');
SELECT CURRENT_DATE from DUAL;
SELECT CURRENT_DATE;
hive sql

Join the Discussion

View or add your thoughts below

Comments