Thursday, 2 May 2013

Hive: Import and Export data from HDFS and Local Directory


Import Data from Local Directory:

hive>LOAD DATA LOCAL INPATH '/local/path' OVERWRITE INTO TABLE table-name;

OVERWRITE is optional in latest versions of hive . You can exclude it if you want to  append data in table.

Export Data to Local Directory:

hive>INSERT OVERWRITE LOCAL DIRECTORY '/local dir/path' SELECT * from table-name;

Import Data from HDFS  :

hive>LOAD DATA INPATH '/hdfs/path/to/file' OVERWRITE INTO TABLE tablename;

OVERWRITE is optional in latest versions of hive . You can exclude it if you want to  append data in table.

Export Data to HDFS:

hive>INSERT OVERWRITE DIRECTORY  /path/to/hdfs' SELECT * FROM tablename;

No comments:

Post a Comment