Hive Practice Lab 2


Welcome one and all to hive learning session 2

In this post we are going to learn about Altering and droping Tables in hive

I guess you already install hadoop and hive
if not
Install hadoop using the steps mention here > Hadoop Installation
To install hive please go through these steps > Hive Installation

once you installed both of above we are ready to start our hive learning session 2 after completion of basic learning

Alter Options :
what we have earlier



First we are going to alter table name i.e from invites to invite;

ALTER TABLE table_name RENAME TO new_table_name

hive> ALTER TABLE invites RENAME TO invite;
hive> show tables;




Now adding new column to it new_col
(please check output screenshot)

ALTER TABLE table_name ADD COLUMNS (col_spec[, col_spec ...])

hive> ALTER TABLE invite ADD COLUMNS (new_col INT);
hive> show tables;




here we are changing column name (please find output screen shot)

ALTER TABLE table_name CHANGE column_name new_name new_type

hive>ALTER TABLE invite CHANGE new_col changed_column string;





hive> ALTER TABLE invites REPLACE COLUMNS(foo INT, bar STRING, baz INT COMMENT 'baz replaces new_col2');

Note that REPLACE COLUMNS replaces all existing columns and only changes
the table's schema, not the data. The table must use a native SerDe.
REPLACE COLUMNS can also be used to drop columns from the table's schema:



Dropping tables:
hive> DROP TABLE pokes;
pokes table is droped



Comment below for post improvement and you suggestion


Reference :https://cwiki.apache.org/confluence/display/Hive/GettingStarted

Incoming Tags:
Hive, Hive Configuration, Hive Practice, Hive Lab, hadoop hive, learn hive, Hive for beginner, learn hive from basic, Leaning hive, learning hadoop
Subscribe us :   www.hadoopquiz.blogspot.com for more updates