Hive导入hdfs数据(2) 上一遍Hive导入hdfs数据(1)中存在1个问题,导入文件后,文件路径会被移动,如果不想移动文件怎么办?

上一遍Hive导入hdfs数据(1)中存在1个问题,导入文件后,文件路径会被移动,如果不想移动文件怎么办?


准备文件 E:\hive\hdfs2.txt


存储到hdfs中


hive创建外部表

hive> create external table if not exists hdfs2(id STRING, name STRING)
. . > row format delimited fields terminated by ','

. . > location '/chy-data/';

显示数据

hive> select * from hdfs2;


删除文件

D:\Soft\hadoop-2.7.6\sbin>hadoop fs -rm  hdfs://localhost:9000/chy-data/hdfs2.txt
18/07/11 16:18:30 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.

Deleted hdfs://localhost:9000/chy-data/hdfs2.txt

hive显示数据

hive> select * from hdfs2;

No rows selected (0.636 seconds)

发现数据没有了,说明动态从文件读取数据显示,数据并不是一次性的读取存储

再次导入数据,发现数据又恢复了

猜你喜欢

转载自blog.csdn.net/chy2z/article/details/81001716