Hive: Tables

(Last Updated On: )

This tutorial will show you some common usage for working with tables. If you have no installed Hive yet please follow this tutorial.

Show Tables:

  1. SHOW TABLES;
    SHOW TABLES LIKE '*test*';

Table Creation:

  1. CREATE TABLE test (
    columnA STRING,
    columnB VARCHAR(15),
    columnC INT,
    columnD TIMESTAMP,
    columnE DATE
    )
    STORED AS ORC;

Table Creation with Partitioning:

  1. CREATE TABLE test_partition (
    columnA STRING,
    columnB VARCHAR(15),
    columnC INT,
    columnD TIMESTAMP,
    columnE DATE
    )
    PARTITIONED BY (columnF INT)
    STORED AS ORC;

Inline Table Creation:

  1. CREATE TABLE test_inline STORED AS ORC AS
    SELECT *
    FROM test;

Temporary Table Creation:

  1. CREATE TEMPORARY TABLE temp (
    columnA STRING,
    columnB VARCHAR(15),
    columnC INT,
    columnD TIMESTAMP,
    columnE DATE
    )
    STORED AS ORC;

DESC Table:
This will show you the basic definition of a table.

  1. DESC test;

DESC EXTENDED Table:
This will show you the extended definition of a table.

  1. DESC EXTENDED test;

Drop Table:

  1. DROP TABLE IF EXISTS temp;