Hive has the EXPORT IMPORT feature since hive 0.8. With this
feature you can export the metadata as well as the data for a corresponding
table to a file in hdfs using the EXPORT command. The data is stored in json
format. Data once exported this way could be imported back to another database
or hive instance using the IMPORT command.
The syntax looks something like this:
EXPORT TABLE table_or_partition TO hdfs_path;
IMPORT [[EXTERNAL] TABLE table_or_partition] FROM hdfs_path [LOCATION [table_location]];
EXPORT TABLE table_or_partition TO hdfs_path;
IMPORT [[EXTERNAL] TABLE table_or_partition] FROM hdfs_path [LOCATION [table_location]];
Some sample statements would look like:
EXPORT TABLE
<table name> TO 'location in hdfs';
Use test_db;
IMPORT FROM 'location
in hdfs';
Export Import can be
appled on a partition basis as well:
EXPORT TABLE
<table name> PARTITION (loc="USA") to 'location in hdfs';
The below import commands
imports to an external table instead of a managed one
IMPORT EXTERNAL TABLE
FROM 'location in hdfs' LOCATION ‘/location/of/external/table’;
No comments:
Post a Comment