我有一个表在RDBMS像这样:蜂巢表创建一个默认值
create table test (sno number, entry_date date default sysdate).
现在我想创建一个蜂巢表的结构如添加一个默认值的列。
我有一个表在RDBMS像这样:蜂巢表创建一个默认值
create table test (sno number, entry_date date default sysdate).
现在我想创建一个蜂巢表的结构如添加一个默认值的列。
蜂房不支持默认域
并不意味着你不能做到这一点,虽然。只需两步创建一个“分段”表格,然后插入第二个表格并选择“默认”值。
Adding a default value to a column while creating table in hive
既然你提到,
我已经表RDBMS
你也可以使用现有的表,并使用Sqoop将数据导入到蜂巢。
我没有通过sqoop导入任何数据。只是我试图在配置单元中创建RDBMS表的副本。 –
当然。我的意思是,这是一个选项 –
Hive目前不支持在创建表格时向任何列添加默认值的功能。 作为解决方法,临时将数据加载到临时表中,并使用插入覆盖表语句将当前日期和时间添加到主表中。
创建的临时表
create table test (sno number);
将数据装载到表
创建最终表
create table final_table (sno number, createDate string);
将临时表中的数据最终加载到最终表。
insert overwrite table final_table select sno, FROM_UNIXTIME(UNIX_TIMESTAMP(), 'dd/MM/YYYY') from test;
,而不是创建我们可以创建这样的stg表。创建表格最终(sno int,jdate日期); insert into final select 1,substr(from_unixtime(unix_timestamp()),1,10);从final中插入最终的select MAX(sno)+1,substr(from_unixtime(unix_timestamp()),1,10); –
那你试试?你面临的问题究竟是什么?显示一些代码。 – Roshith