Monday, November 9, 2015

Hive Commands

1. View table or schema details

Command
hive> DESCRIBE FORMATTED <tablename>;
hive> DESCRIBE EXTENDED <tablename>;

2. Alter Table

Command
hive> ALTER TABLE employee RENAME TO emp;
hive> ALTER TABLE emp ADD COLUMNS(salary INT);
hive> ALTER TABLE emp CHANGE salary sal INT;
hive> ALTER TABLE emp CHANGE sal sal STRING;

3. Add Jars into Hive Classpath

Command
hive> ADD JAR <jarname.jar>; - look for current directory
hive> ADD JAR /test/jars/<jarname.jar>;
hive> LIST JARS; - displays all the jars in the classpath

4. Load data to hive table from subdirectories

Command
hive> SET mapred.input.dir.recursive=true;
hive> SET hive.mapred.supports.subdirectories=true;
hive> SET mapred.input.dir.recursive=true;

No comments :

Post a Comment