gpt4 book ai didi

MySQL 工作台 - 链接表

转载 作者:行者123 更新时间:2023-11-29 02:52:07 27 4
gpt4 key购买 nike

我试图通过创建名为“Klantwinkel”的第三个表来链接“Klant”和“Winkel”。这是我的代码:

CREATE TABLE Klant (
klantnummer int(10) not NULL,
voornaam varchar(10) not NULL,
achternaam varchar(10) not NULL,
adres varchar(20) not NULL,
e_mail varchar(40) not NULL,
primary key(klantnummer)
);

CREATE TABLE Winkel (
winkelnummer int(4) not NULL,
winkelnaam varchar(20) not NULL,
winkeladres varchar(30) not NULL,
primary key(winkelnummer)
);

CREATE TABLE Klantwinkel (
klantnummer int(10) not NULL,
winkelnummer int(4) not NULL,
primary key(klantnummer, winkelnummer),
foreign key(klantnummer) references klant(klantnummer),
foreign key(winkelnummer) references Winkel(winkelnummer)
);

我收到错误代码 1005。有人可以帮助我吗?新年快乐!

编辑:我想我有一个看不见的资本错误。我重写了每个单词的第一个字母,现在突然可以用了!

 foreign key(klantnummer) references klant(klantnummer),

'klant' 没有大写字母 K。

最佳答案

表名在 UNIX 中区分大小写,但在 Windows 环境中不区分大小写。默认情况下,在 MySQL 可配置文件中,该值为 lower_case_table_names=0。0 代表区分大小写,这发生在你的情况下并给出了错误。根据文档-

System Variable Name    lower_case_table_names
Variable Scope Global
Dynamic Variable No
Permitted Values Type integer
Default 0
Min Value 0
Max Value 2

If set to 0, table names are stored as specified and comparisons are case sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases. For additional information, see Section 9.2.2, “Identifier Case Sensitivity”.

On Windows the default value is 1. On OS X, the default value is 2.

You should not set lower_case_table_names to 0 if you are running MySQL on a system where the data directory resides on a case-insensitive file system (such as on Windows or OS X). It is an unsupported combination that could result in a hang condition when running an INSERT INTO ... SELECT ... FROM tbl_name operation with the wrong tbl_name letter case. With MyISAM, accessing table names using different letter cases could cause index corruption.

来源- http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html

关于MySQL 工作台 - 链接表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34557054/

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