Select from dual in SQL / Hive

access_time 2 years ago visibility661 comment 0

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;
info Last modified by Raymond at 2 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Want to publish your article on Kontext?

Learn more

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer hive local_offer SQL local_offer hive-sql-ddl

visibility 80
thumb_up 1
access_time 3 months ago

This page shows how to create Hive tables with storage file format as Parquet, Orc and Avro via Hive SQL (HQL). The following examples show you how to create managed tables and similar syntax can be applied to create external tables if Parquet, Orc or Avro format already exist in HDFS. Example ...

local_offer Java local_offer hive

visibility 2618
thumb_up 0
access_time 2 years ago

This post shows you how to connect to HiveServer2 via Hive JDBC driver in Java. *The way to connect to HiveServer1 is very similar though the driver names are different: Version Driver Name HiveServer1 org.apache.hadoop.hive.jdbc.HiveDriver HiveServer2 ...

local_offer SQL local_offer hive

visibility 5231
thumb_up 1
access_time 12 months ago

In different databases, the syntax of selecting top N records are slightly different. They may also differ from ISO standards.

About column

Code snippets and tips for various programming languages/frameworks.

rss_feed Subscribe RSS