CREATE TABLE t1 (name STRING);
LOAD DATA LOCAL INPATH '/home/grid/a.txt' INTO TABLE t1;
SELECT * FROM t1;
dfs -ls /user/hive/warehouse/test.db/t1;
执行命令及结果如图1所示。
LOAD DATA LOCAL INPATH '/home/grid/a.txt' INTO TABLE t1;
SELECT * FROM t1;
dfs -ls /user/hive/warehouse/test.db/t1;
执行命令及结果如图2所示。
CREATE TABLE t2 (name STRING);
LOAD DATA LOCAL INPATH '/home/grid/a.txt' OVERWRITE INTO TABLE t2;
SELECT * FROM t2;
dfs -ls /user/hive/warehouse/test.db/t2;
执行命令及结果如图3所示。
LOAD DATA LOCAL INPATH '/home/grid/a.txt' OVERWRITE INTO TABLE t2;
SELECT * FROM t2;
dfs -ls /user/hive/warehouse/test.db/t2;
执行命令及结果如图4所示。
drop table t1;
drop table t2;
show tables;
dfs -ls /user/hive/warehouse/test.db;
执行命令及结果如图5所示。
CREATE TABLE t1 (name STRING) PARTITIONED BY (country STRING, state STRING);
LOAD DATA LOCAL INPATH '/home/grid/a.txt' INTO TABLE t1 PARTITION (country = 'US', state = 'CA');
SELECT * FROM t1;
dfs -ls /user/hive/warehouse/test.db/t1/country=US/state=CA;
执行命令及结果如图6所示。
SELECT * FROM t1;
ALTER TABLE t1 ADD PARTITION(country = 'US', state = 'CB') LOCATION '/a';
dfs -cp /user/hive/warehouse/test.db/t1/country=US/state=CA/a.txt /a;
dfs -ls /a;
SELECT * FROM t1;
dfs -rm /user/hive/warehouse/test.db/t1/country=US/state=CA/a.txt;
SELECT * FROM t1;
执行命令及结果如图7所示。
dfs -ls /user/hive/warehouse/test.db;
dfs -ls /;
drop table t1;
show tables;
dfs -ls /user/hive/warehouse/test.db;
dfs -ls /;
执行命令及结果如图8所示。