MySQL工作台 - 链接表

时间:2016-01-01 14:37:14

标签: mysql

我正在尝试将'Klant'和& 'Winkel'制作了第三张名为'Klantwinkel'的桌子。 这是我的代码:

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.

1 个答案:

答案 0 :(得分:1)

表名在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