hive drop表恢復手冊

2022-07-07 21:30:18 字數 1840 閱讀 1918

version information: purge

the purge option is added in version 0.14.0 by hive-7100.

如果指定了 purge,則表資料不會轉到. trash /current目錄,因此在出現錯誤的刪除時無法恢復。清洗選項也可以通過表屬性 auto.purge 指定。清除(參見上面的tblproperties)。

hive 0.7.0或更高版本中,如果表不存在,drop返回乙個錯誤,除非指定了if exists,或者配置變數hive.exec.drop.ignorenonexistent設定為true

partition_spec:

(partition_column = partition_col_value, partition_column = partition_col_value, ...)`

刪除表或分割槽中的所有行。如果啟用了檔案系統trash ,這些行將被丟棄在指定目錄,否則它們將被刪除(從hive 2.2.0 with hive-14626開始)。當前目標表應該是本地/管理表,否則將引發異常。使用者可以指定部分 partition_spec來一次 truncate 多個分割槽,省略partition_spec將 truncate 表中的所有分割槽。

hive 2.3.0 (hive-15880)開始,如果表屬性auto.purge(參見上面的tblproperties)設定為true,當對表發出truncate table命令時,表的資料不會被移動到trash,並且資料無法恢復。這只適用於管理表。如果管理表沒有設定auto.purge屬性或者設定為false這個功能被關閉。

了解下dorp命令在hdfs中的操作:

create table `user`(

`locationareaid` bigint,

`locationareaname` string

)partitioned by (

`dt` string)

row format delimited fields terminated by '\t' line terminated by '\n' stored as textfile;

hdfs dfs -cp /user/hadoop/.trash/current/user/hive/warehouse/user/dt=2019-10-161571499856584   /user/hive/warehouse/user
load data inpath '/user/hive/warehouse/user/dt=2019-10-171571499859193/part-m-00000' into table user partition (dt='2019-10-171571499859193');
方案二 如果分割槽過多的話.方案一會很耗時可以是用msck repair table操作來載入分割槽,在執行命令前,

注意:一定保證分割槽所處的位置是正確的.

msck repair table user
select * from  user where dt='2019-10-171571499859193'
本文由部落格一文多發平台 openwrite 發布!

ORACLE刪錯表恢復語句,表恢復

一 表的恢復 對誤刪的表,只要沒有使用purge永久刪除選項,那麼從flash back區恢復回來希望是挺大的。一般步驟有 1 從flash back裡查詢被刪除的表 select from recyclebin 2.執行表的恢復 flashback table tb to before drop,...

Oracle刪除表恢復

恢復當天刪除了表而沒有記住表的名稱 儲存過程如下 create or replace procedure proc databack deletetime in varchar2 as 把當天已經刪除的資訊查詢出來放入游標 cursor mycursor is select object name ...

Truncate 表之恢復

truncate 表之恢復 1.測試環境 linux 172.28.145.21 db testdb01 2.原理 truncate 不會逐個清除使用者資料塊上的資料,而僅僅重置資料字典和元資料塊上的元資料 如儲存斷頭和擴充套件段圖 也就是說,此時,基本資料表並未破壞,而是被系統 等待被重新分配 因...