· 7 years ago · Jan 09, 2019, 06:08 PM
1# Create table based on file meta
2CREATE TABLE IF NOT EXISTS new_york
3(
4 year int,
5 leading_cause string,
6 sex string,
7 race_ethnicity string,
8 deaths int,
9 death_rate float,
10 age_adjusted_death_rate float
11)
12 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u003B'
13 STORED AS ORC;
14
15# Load data from uploaded file
16LOAD DATA INPATH '/user/maria_dev/data/big_data_dane.csv' OVERWRITE INTO TABLE new_york
17
18 Create an external table.
19
20An external table is a table for which Hive does not manage storage. If you delete an external table, only the definition in Hive is deleted. The data remains. An internal table is a table that Hive manages. If you delete an internal table, both the definition in Hive and the data are deleted.
21
22The following command creates an external table:
23
24 CREATE EXTERNAL TABLE IF NOT EXISTS new_york_data
25(
26 year int,
27 leading_cause string,
28 sex string,
29 race_ethnicity string,
30 deaths int,
31 death_rate float,
32 age_adjusted_death_rate float
33)
34 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u0059'
35 STORED AS TEXTFILE
36 location '/user/maria_dev/data/big_data_dane.csv';