【发布时间】:2022-01-03 19:37:38
【问题描述】:
在执行我的 hql 脚本的过程中,我必须先将数据存储到临时表中,然后再插入到主表中。 在那种情况下,我尝试创建一个在开头带有下划线的临时表。
注意:带引号的表名和下划线不起作用。
工作创建声明:
create table
dbo.`_temp_table` (
emp_id int,
emp_name string)
stored as ORC
tblproperties ('ORC.compress' = 'ZLIB')';
工作插入语句:
insert into table dbo.`_temp_table` values (123, 'ABC');
但是,临时表上的 select 语句不起作用,即使我们按照 insert 语句插入了记录,它也显示空记录。
select * from dbo.`_temp_table`;
一切正常,但 用于查看行的选择语句不起作用。 我仍然不确定,我们可以通过上述方式创建一个临时表吗???
【问题讨论】:
-
您的数据库是否命名为
dbo?在您的 create table 语句的实际代码中,在语句结束之前是否有一个',即问题中的('ORC.compress' = 'ZLIB')';还是一个类型,而您的实际代码是('ORC.compress' = 'ZLIB');? -
还有其他的说法吗?我无法重现您的问题。我在 hive 2.3 上运行了没有
dbo和('ORC.compress' = 'ZLIB');修正的共享语句,并收到了插入记录的结果。 -
尝试做同样的事情,但从创建表中删除 dbo 并选择。在所有内容之前添加
use dbo;,作为会话中的第一条语句 -
@ggordon,是的,这是一个拼写错误。
-
我试过不提供数据库名称,输出和以前一样。 select 语句无法检索插入的记录。但是,创建、插入和删除语句工作正常。执行查询:
1. use dbo; 2. create table `_temp_table` (emp_id int, emp_name string) stored as ORC tblproperties ('ORC.compress' = 'ZLIB'); 3. insert into table `_temp_table` values (123, 'ABC'); 4. select * from `_temp_table`;(注意
标签: sql hive hiveql temp-tables hiveddl