create table article( id int, title string, type string, data_time int, source string, content string, primary key (id) DISABLED) > ROW FORMAT DELIMITED FIELDS TERMINATED BY ','; FAILED: ParseException line 1:133 extraneous input 'DISABLED' expecting ) near '<EOF>'
时间: 2023-12-03 17:44:21 浏览: 249
在创建表时,`DISABLED`是不必要的关键字,因此需要将其移除。下面是正确的语法:
```
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 ',';
```
在这个语法中,我们通过使用 `ROW FORMAT DELIMITED FIELDS TERMINATED BY ','` 来指定行的分隔符以及列的分隔符。同时,我们将 `primary key` 作为表的一部分来定义,以确保 `id` 列成为表的主键。
相关问题
create table article( > id int, > title string, > type string, > data_time int, > source string, > content string, > primary key (id) > ); FAILED: SemanticException [Error 10326]: Invalid Constraint syntax ENABLE/ENFORCED feature not supported yet. Please use DISABLE/NOT ENFORCED instead.
这个错误提示是因为在创建表时,使用了不支持的约束语法。根据错误提示,你需要将约束中的 "ENABLE/ENFORCED" 改为 "DISABLE/NOT ENFORCED",如下所示:
```
create table article(
id int,
title string,
type string,
data_time int,
source string,
content string,
primary key (id) DISABLED
);
```
这样就可以成功创建表了。注意,这里我们将主键约束禁用了,如果需要启用主键约束,只需将 "DISABLED" 改为 "ENABLED" 即可。
阅读全文