Hive provides a default interface, where it allows users to run Hive commands. The CLI (Command Line Interface) is the default Hive shell service which allows users to work on Hive programs.
Creating a Database:
hive> create databse sampledb;
Listing Databases:
hive> SHOW DATABASES;
Using a Database:
hive> use sampledb;
Creating a Table:
The create table command allows the user to create a new table with user input attributes/columns
Row format delimited Fields terminated by ‘\t’ – This line informsHive that each column in the file is separated by a tab.
hive> Create table emp(empid int, empname string, empsal float)
> row format delimited
> fields terminated by ‘\t’ ;
List Tables:
The ‘show tables’ command displays the list of tables present in a particular database.
Hive> show Tables;
Describe Schema of the Table:
hive>DESCRIBE emp;
Load a File from the Local File System:
hive>load data local inpath<filename> into table emp;
Load File from HDFS:
hive>load data inpath<filename> into table<tablename>
Show Table Contents:
hive>select * from emp;
Alter Commands:
hive> ALTER TABLE EMP RENAME TO EMP_1
Adding New Columns to an Existing Table:
hive> alter table emp_1 add columns (DOB DATE);
Truncating a Table:
hive> truncate table emp_1;
Dropping a Database:
hive> drop databse sampledb;
Creating a Database:
hive> create databse sampledb;
Listing Databases:
hive> SHOW DATABASES;
Using a Database:
hive> use sampledb;
Creating a Table:
The create table command allows the user to create a new table with user input attributes/columns
Row format delimited Fields terminated by ‘\t’ – This line informsHive that each column in the file is separated by a tab.
hive> Create table emp(empid int, empname string, empsal float)
> row format delimited
> fields terminated by ‘\t’ ;
List Tables:
The ‘show tables’ command displays the list of tables present in a particular database.
Hive> show Tables;
Describe Schema of the Table:
hive>DESCRIBE emp;
Load a File from the Local File System:
hive>load data local inpath<filename> into table emp;
Load File from HDFS:
hive>load data inpath<filename> into table<tablename>
Show Table Contents:
hive>select * from emp;
Alter Commands:
hive> ALTER TABLE EMP RENAME TO EMP_1
Adding New Columns to an Existing Table:
hive> alter table emp_1 add columns (DOB DATE);
Truncating a Table:
hive> truncate table emp_1;
Dropping a Database:
hive> drop databse sampledb;
No comments:
Post a Comment