gpt4 book ai didi

mysql - 第一次sql数据库创建表名区域显示为红色

转载 作者:行者123 更新时间:2023-11-29 13:14:52 26 4
gpt4 key购买 nike

嗨,我正在创建一个sql数据库,这是第一次手写代码,我正在使用phpMyAdmin来创建数据库。我正在创建名为“主题”、“级别”、“区域”和“原则”的表格;它们都将使用外键相互链接,但我注意到在输入表名称 Area 时,它会以红色显示任何想法或简单的解释。

到目前为止我的代码是:

   CREATE TABLE subject (
subject_id VARCHAR (50) PRIMARY KEY,
description VARCHAR (200),
FOREIGN KEY (level_id) REFERENCES level(level_id),
FOREIGN KEY (area_id) REFERENCES area(area_id),
FOREIGN KEY (principle_id) REFERENCES principle(principle_id)
) Engine = InnoDB;

INSERT INTO subject (subject_id, description)VALUES
('Mathematics', 'this is the maths description'),
('English', 'this is the description'),
('Science', 'this is the science description'),
('Computing', 'this is the computing description'),
('Design and Technology', 'this is the Design and technology description'),
('Art', 'this is the Art description');

CREATE TABLE level (
level_id VARCHAR (50) PRIMARY KEY,
description VARCHAR (200),
FOREIGN KEY (subject_id) REFERENCES subject(subject_id),
FOREIGN KEY (area_id) REFERENCES area(area_id),
FOREIGN KEY (principle_id) REFERENCES principle(principle_id)
) Engine = InnoDB;

INSERT INTO level (level_id, description)VALUES
('Key Stage 1', 'this is year 1 - 2 in school'),
('Key Stage 2', 'this is year 3 - 6 in school'),
('Key Stage 3', 'this is year 7 - 9 in school'),
('Key Stage 4', 'this is year 10 - 11 in school'),
('Key Stage 5', 'this is year 12 - 13 in school');

CREATE TABLE area (
area_id VARCHAR (50) PRIMARY KEY,
description VARCHAR (200),
FOREIGN KEY (subject_id) REFERENCES subject(subject_id),
FOREIGN KEY (level_id) REFERENCES level(level_id),
FOREIGN KEY (principle_id) REFERENCES principle(principle_id)
) Engine = InnoDB;

发生这种情况的代码行是

     FOREIGN KEY (area_id) REFERENCES area(area_id),

是因为这个词代表其他东西而你无法创建一个名为area的表还是可以?

最佳答案

MySQL 认为您正在尝试引用 Polygon Area Function - 你最好引用“区域”,如 @Rag 的第一条评论中详细说明的那样。

关于mysql - 第一次sql数据库创建表名区域显示为红色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21602177/

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