gpt4 book ai didi

mysql - 无法创建 SQL 表 [SQL]

转载 作者:行者123 更新时间:2023-11-29 05:37:20 26 4
gpt4 key购买 nike

我不确定我在这里创建的表有什么问题。一直给我错误

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use
near 'character
(
character_id VarChar(15) PRIMARY KEY,
name VarChar(30) NOT NULL,
sex' at line 1

我没有看到任何错误吗?

CREATE TABLE character
(
character_id VarChar(15) PRIMARY KEY,
name VarChar(30) NOT NULL,
sex VarChar(7) NOT NULL,
age INT NOT NULL,
hair VarChar(10) NOT NULL,
eye VarChar(10) NOT NULL,
skin VarChar(12) NOT NULL,
body VarChar(12) NOT NULL,
from VarChar(20) NOT NULL
) engine=innobd;

最佳答案

characterfrom是MySQL中的保留字:http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

要将保留字用作字段/表标识符,您必须用反引号将其引用:

create table `character` (
...
body VarChar(12) NOT NULL,
`from` VarChar(20) NOT NULL
...

关于mysql - 无法创建 SQL 表 [SQL],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9571362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com