Database Reference
In-Depth Information
hive> SELECT * FROM stations LIMIT 4;
010000 99999 BOGUS NORWAY
010003 99999 BOGUS NORWAY
010010 99999 JAN MAYEN
010013 99999 ROST
As this example demonstrates, RegexSerDe can be useful for getting data into Hive, but
due to its inefficiency it should not be used for general-purpose storage. Consider copying
the data into a binary storage format instead.
Storage handlers
Storage handlers are used for storage systems that Hive cannot access natively, such as
HBase. Storage handlers are specified using a STORED BY clause, instead of the ROW
FORMAT and STORED AS clauses. For more information on HBase integration, see the
Hive wiki .
Importing Data
We've already seen how to use the LOAD DATA operation to import data into a Hive
table (or partition) by copying or moving files to the table's directory. You can also popu-
late a table with data from another Hive table using an INSERT statement, or at creation
time using the CTAS construct, which is an abbreviation used to refer to CREATE
TABLE...AS SELECT .
If you want to import data from a relational database directly into Hive, have a look at
Sqoop; this is covered in Imported Data and Hive .
Inserts
Here's an example of an INSERT statement:
INSERT OVERWRITE TABLE target
SELECT col1, col2
FROM source;
For partitioned tables, you can specify the partition to insert into by supplying a
PARTITION clause:
INSERT OVERWRITE TABLE target
PARTITION (dt='2001-01-01')
SELECT col1, col2
FROM source;
Search WWH ::




Custom Search