2016-11-24 42 views
0

在實踐中,我已經創建了tmp表,使用蜂巢提示中的以下查詢。蜂巢臨時表自動刪除

$create temporary table tmp (id int); 

現在表是越來越成功創建,如果我關閉蜂巢會話表將被蜂房根據文檔這是真正的自動刪除。

現在,還有其他方法可以通過使用以下命令來運行相同的查詢。是越來越成功創建

$hive -e 'create temporary table tmp (id int);' 

表,但我懷疑這個時候,爲什麼TMP表不會得到自動刪除這一次。執行下一個命令後,我仍然可以看到tmp表。

$hive -e 'show tables;' 
OK 
customers 
order 
product 
tmp 
Time taken: 0.856 seconds, Fetch: 4 row(s) 

回答

0

很可能你已經擁有同名的表,但不是臨時表。

的步驟重現:

我已經檢查,有沒有這樣的表(不是暫時的)已經存在。

hive -e 'use myschema; show tables "tmp";' 
--no rows returned 

然後我跑你的例子:

$hive -e 'use myschema; create temporary table tmp (id int);' 
OK 

檢查有沒有表:

hive -e 'use myschema; show tables "tmp";' 
--no rows returned - it works correctly 

創建不是臨時

hive -e 'use myschema; create table tmp (id int);' 
--ok 

現在有持續性表:

hive -e 'use myschema; show tables "tmp";' 
OK 
tmp 
Time taken: 0.081 seconds, Fetched: 1 row(s) 

嘗試創建相同的臨時表:

hive -e 'use myschema; create temporary table tmp (id int);' 
OK 

持久表格保留在架構。臨時表已成功刪除,臨時表在會話中被隔離,其他會話不可見。