April 2016
Beginner
268 pages
5h 32m
English
Partitioning external tables works in the same way as in managed tables. Except this in the external table, when you delete a partition, the data file doesn't get deleted.
First create an EXTERNAL table for the customer data using the following command:
CREATE EXTERNAL TABLE customer_external(id STRING, name STRING, gender STRING, state STRING) PARTITIONED BY (country STRING);
Now a partition can be added to the EXTERNAL table, using the ALTER TABLE ADD PARTITION command:
ALTER TABLE customer_external ADD PARTITION(country='UK') LOCATION '/user/hive/warehouse/customer/country=UK'