gpt4 book ai didi

mysql - 以下查询在创建表时出错

转载 作者:行者123 更新时间:2023-11-29 02:45:56 25 4
gpt4 key购买 nike

这个sql查询在执行时给我一个错误我不明白问题出在哪里请在这里帮助我

CREATE TABLE failed: CREATE TABLE projects_of_1-2453852243(proj_id VARCHAR(256) NOT NULL PRIMARY KEY,
title VARCHAR(256),
mentor VARCHAR(128),
team_leader VARCHAR(128),
abstract TEXT, description MEDIUMBLOB,
domain VARCHAR(80),
department VARCHAR(80),
reference VARCHAR(128),
submission_yr int,
proj_field VARCHAR(2))

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-2453852243(proj_id VARCHAR(256) NOT NULL PRIMARY KEY, title VARCHAR(256), mento' at line 1

最佳答案

在您的表名 projects_of_1-2453852243 周围加上反引号,因为标识符中不允许直接使用 -。此外,PRIMARY KEY 已经是 NOT NULL。不需要用主键指定。

CREATE TABLE `projects_of_1-2453852243`(
proj_id VARCHAR(256) PRIMARY KEY,
title VARCHAR(256),
mentor VARCHAR(128),
team_leader VARCHAR(128),
abstract TEXT, description MEDIUMBLOB,
domain VARCHAR(80),
department VARCHAR(80),
reference VARCHAR(128),
submission_yr int,
proj_field VARCHAR(2))

或者改用下划线:

CREATE TABLE projects_of_1_2453852243 (
proj_id VARCHAR(256) PRIMARY KEY,
title VARCHAR(256),
mentor VARCHAR(128),
team_leader VARCHAR(128),
abstract TEXT, description MEDIUMBLOB,
domain VARCHAR(80),
department VARCHAR(80),
reference VARCHAR(128),
submission_yr int,
proj_field VARCHAR(2))

关于mysql - 以下查询在创建表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42179773/

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