蜂巢,创建表___,例如___,存储为___

Vik*_*oel 4 hadoop hive

我有一个配置单元中的表格存储为文本文件。我想将所有数据移动到具有相同模式但存储为序列文件的另一个表中。如何创建第二张表?我想使用hive create table like命令,但不支持as sequencefile

hive> create table test_sq like test_t stored as sequencefile;
FAILED: ParseException line 1:33 missing EOF at 'stored' near 'test_t'
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种编程方式,以便可以为更多表复制相同的过程。

Kis*_*ore 5

CREATE TABLE test_t LIKE test_sq;
Run Code Online (Sandbox Code Playgroud)

它只是复制源表定义。新表不包含任何行。如您所说,您必须移动所有数据。在这种情况下,上面的查询不合适。

尝试这个,

CREATE TABLE test_sq row format delimited fields terminated by '|' STORED AS sequencefile AS select * from test_t;
Run Code Online (Sandbox Code Playgroud)
  • 目标无法分区表。
  • 目标不能是外部表。
  • 它复制结构和数据

注意-如果您不想给行格式定界,请从查询中删除。您还可以在查询中提供where子句以复制选定的行;