Open
Description
I tried using 3 versions: 4.5, 4.6, 4.7.
I want to get table name from this sql:
CREATE TABLE `sys_user`
(
`id` bigint NOT NULL,
`role_id` bigint NULL,
`name` varchar (255) NULL,
`age` int NULL,
`remark` longtext NULL,
`local` varchar (255) NULL,
`address` varchar (255) NULL,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `ina_index` (`id`,`name`,`age`) USING BTREE COMMENT 'Unique index of id, name, age',
INDEX (`local`) USING BTREE COMMENT 'Index of local',
FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`role_id`)
)
They all gave me the same error
Exception in thread "main" net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "UNIQUE" "UNIQUE"
at line 10, column 3.
Was expecting one of:
"ACTION"
"ACTIVE"
"ALGORITHM"
"ARCHIVE"
"ARRAY"
"AT"
"BYTE"
"CASCADE"
When I modify the sql
CREATE TABLE `sys_user`
(
`id` bigint NOT NULL,
`role_id` bigint NULL,
`name` varchar (255) NULL,
`age` int NULL,
`remark` longtext NULL,
`local` varchar (255) NULL,
`address` varchar (255) NULL,
PRIMARY KEY (`id`) ,
UNIQUE (`id`,`name`,`age`) USING BTREE COMMENT 'Unique index of id, name, age',
INDEX (`local`) USING BTREE COMMENT 'Index of local',
FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`role_id`)
)
The execution was successful
The difference between the two SQLs lies in the UNIQUE part