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


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

Hive导入hdfs数据(2)

存储到hdfs中

Hive导入hdfs数据(2)

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;

Hive导入hdfs数据(2)

删除文件

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)

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

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

相关文章:

  • 2021-08-31
  • 2021-11-15
  • 2021-04-15
  • 2021-12-31
  • 2022-01-20
  • 2022-02-06
猜你喜欢
  • 2021-11-07
  • 2021-09-22
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案