2016-11-24 43 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 

持久表格保留在架构。临时表已成功删除,临时表在会话中被隔离,其他会话不可见。