Skip to content

Instantly share code, notes, and snippets.

@sudheer-k-bhat
Created February 20, 2021 05:18
Show Gist options
  • Save sudheer-k-bhat/e5a0dbeffbd1f131570bbf1efa981d27 to your computer and use it in GitHub Desktop.
Save sudheer-k-bhat/e5a0dbeffbd1f131570bbf1efa981d27 to your computer and use it in GitHub Desktop.
Basic Hive commands

Working examples

Create table

hive> create table categories(
    category_id int,
    category_department_id int,
    category_name varchar(45))
    row format delimited
    fields terminated by ','
    stored as textfile;

Create external table

create external table categories(..) row format ...
    location '/external/categories'
    stored as textfile;

Load data from HDFS

load data inpath '/retail-db/categories' into table categories;

Overwrite data from HDFS

load data inpath '/retail-db/categories' overwrite into table categories;

Import text file

create table batting(
    name varchar(45),
    tests int,
    innings int,
    no int,
    runs int,
    high varchar(5),
    cent int,
    fifty int,
    duck int,
    country varchar(45)
) row format delimited fields terminated by ',' stored as textfile;
load data local inpath '/home/sois/bat.txt' into table batting;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment