CREATE TABLE article ( id INT, title STRING, type STRING, data_time INT, source STRING, content STRING, PRIMARY KEY (id)) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','TBLPROPERTIES ("CONSTRAINT"="PRIMARY KEY (id) DISABLE NOVALIDATE"); FAILED: SemanticException [Error 10326]: Invalid Constraint syntax ENABLE/ENFORCED feature not supported yet. Please use DISABLE/NOT ENFORCED instead. hive> CREATE TABLE article ( id INT, title STRING, type STRING, data_time INT, source STRING, content STRING, PRIMARY KEY (id)) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' TBLPROPERTIES ("CONSTRAINT"="PRIMARY KEY (id) NOT ENFORCED"); FAILED: SemanticException [Error 10326]: Invalid Constraint syntax ENABLE/ENFORCED feature not supported yet. Please use DISABLE/NOT ENFORCED instead.
时间: 2023-11-30 08:03:25 浏览: 223
CreateTable.rar_create table ja_createTab_createTable
在创建表时,Hive不支持启用或强制执行约束。你需要使用`DISABLE`或`NOT ENFORCED`关键字来替换`ENABLE`或`ENFORCED`关键字。下面是正确的创建表的语法:
```
CREATE TABLE article (
id INT,
title STRING,
type STRING,
data_time INT,
source STRING,
content STRING,
PRIMARY KEY (id)
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
TBLPROPERTIES ("CONSTRAINT"="PRIMARY KEY (id) DISABLE NOVALIDATE");
```
或者,你可以省略`TBLPROPERTIES`部分,如下所示:
```
CREATE TABLE article (
id INT,
title STRING,
type STRING,
data_time INT,
source STRING,
content STRING,
PRIMARY KEY (id) DISABLE NOVALIDATE
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ',';
```
这将创建一个名为`article`的表,并将`id`列指定为主键。`DISABLE NOVALIDATE`选项将禁用约束验证,以便在插入数据时可以使用非唯一的`id`值。
阅读全文