DROP TABLE IF EXISTS `aa_ccd`; CREATE TABLE `aa_ccd` ( `ID` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `CCDCODE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `ICNNAME` varchar(107) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `ISDISEASE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `ENNAME` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `PARENTID` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `YEAR` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `NOTE` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LEFTSPACE` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LIMITED` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LEVEL1` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LEVEL2` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LEVEL3` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `LEVEL4` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, PRIMARY KEY (`ID`) USING BTREE, INDEX `index1`(`CCDCODE`) USING BTREE, INDEX `index2`(`ICNNAME`) USING BTREE, INDEX `index_yes`(`YEAR`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; 这个建表sql在doris数据库执行时报错,[SQL] Query doris_2 start [ERR] 1105 - errCode = 2, detailMessage = Syntax error in line 25: `id` varchar(50) CHARACTER SET utf8mb4 COLLAT... ^ Encountered: CHARACTER Expected: COMMA [ERR] 这是为什么
时间: 2023-08-23 13:07:40 浏览: 117
根据报错信息,可以看到是在第25行出现了语法错误,缺少了逗号。具体来说,是因为在第24行的最后缺少了一个逗号,导致第25行的语句被解析为一个新的字段,而不是原本的字段属性。因此,应该在第24行最后加上逗号,即在 `LEVEL4` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL 后面加一个逗号,就可以解决这个问题了。
相关问题
DROP TABLE IF EXISTS `agency`; CREATE TABLE `agency` ( `id` int(0) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
您正在创建一个名为`agency`的表格,并指定了两个列:`id`和`name`。其中`id`列被定义为整数类型,并使用`AUTO_INCREMENT`属性,以便在插入数据时自动递增。
`name`列被定义为可变长度字符串类型(varchar),最大长度为255个字符。它还指定了字符集(utf8mb4)和排序规则(utf8mb4_0900_ai_ci)。该列允许为空,并且默认值为NULL。
下面是您提供的代码:
```sql
DROP TABLE IF EXISTS `agency`;
CREATE TABLE `agency` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
...
);
```
请注意,我在代码中添加了省略号`...`,这表示您可以继续添加其他列和定义其他表格属性,以满足您的需求。
USE `sys`; DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `admin_id` int(11) NOT NULL AUTO_INCREMENT, `admin_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `admin_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`admin_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; insert into `admin`(`admin_id`,`admin_name`,`admin_password`) values (1,'zxc','abc'),(2,'qwe','acc'); DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `user_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`user_id`) USING BTREE, ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;这段语句的错误
这段语句有一个错误,就是在创建`user`表的语句中,最后有一个逗号,导致语法错误。正确的语句应该是:
```
USE `sys`;
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`admin_id` int(11) NOT NULL AUTO_INCREMENT,
`admin_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`admin_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`admin_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
INSERT INTO `admin`(`admin_id`, `admin_name`, `admin_password`)
VALUES (1, 'zxc', 'abc'), (2, 'qwe', 'acc');
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`user_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
```
阅读全文