hive恢复drop table数据 |
您所在的位置:网站首页 › stata的数据还能恢复吗 › hive恢复drop table数据 |
hive 中使用truncate命令将表截断的话,它是不会进回收站的,是没办法恢复的。这个跟oracle truncate有点类似的。 恢复在hive中通过drop table删除的数据文件就是将hdfs dfs -rm删除掉的文件进行恢复,只需要hdfs dfs -mv将文件从回收站中搬过来就行,我就先使用这个方法,但是效果不佳,执行select count(*) from table_name,得到的结果为0。这个时候我想到这个表被drop掉以后在mysql的元数据库中已经没有数据了,那就得需要将这些数据的信息重新写入到mysql中。具体恢复步骤如下: 1、创建表: CREATE TABLE temp_richard( op_time string, province_id string, pay_type string, client_type string, index_id string, index_value bigint ) PARTITIONED BY (dayid string) stored as rcfile location '/dw/tmp/temp_richard';2、将回收站中的数据cp出来一份 hdfs dfs -cp /user/hadoop/.Trash/Current/dw/dm/tmp_richard /tmp/richard/3、将临时目录下的数据load到表中: load data inpath '/tmp/zhulh/dayid=20160101/000000_0' into table tmp_richard PARTITION (dayid='20160101');备注:这里需要将每个分区的数据load到相应的分区表中。 4、验证数据: hive> select count(*) from tmp_richard;
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |