Saturday, 15 September 2018

Basic Hive commands

To see databases

show databases;
(first time 'default' db will be shown)

Create database

create database <database_name>;

To print database name on the hive prompt

set hive.cli.print.current.db=true;

Change database

use <database_name>;

Create table

create table <tablename> (<columnname> <datatype>, ...) row format delimited fields terminated by ',';
Eg: create table newtable(id int, name string, mobileno bigint) row format delimited fields terminated by ',';

To see tables

show tables;

To see the structure of a table

describe <tablename>;

Insert data into a table

load data local inpath '<path of the text file>' into table <tablename>;

No comments:

Post a Comment