質問編集履歴
2
指摘のあった外部キーの名前を、暫定で重複の無いよう変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -49,13 +49,13 @@
|
|
49
49
|
items_genre VARCHAR(191) NOT NULL,
|
50
50
|
items_material VARCHAR(191) NOT NULL,
|
51
51
|
items_color VARCHAR(191) NOT NULL,
|
52
|
-
FOREIGN KEY fkey
|
52
|
+
FOREIGN KEY fkey2 (makers_id) REFERENCES makers(makers_id)
|
53
53
|
);
|
54
54
|
CREATE TABLE itemsinfo(
|
55
55
|
items_id INT,
|
56
56
|
itemsinfo_size VARCHAR(191),
|
57
57
|
itemsinfo_stock INT NOT NULL,
|
58
|
-
FOREIGN KEY fkey
|
58
|
+
FOREIGN KEY fkey3 (items_id) REFERENCES items(items_id),
|
59
59
|
PRIMARY KEY(items_id, itemsinfo_size)
|
60
60
|
);
|
61
61
|
CREATE TABLE details(
|
@@ -63,9 +63,9 @@
|
|
63
63
|
items_id INT,
|
64
64
|
itemsinfo_size VARCHAR(191),
|
65
65
|
details_vol INT NOT NULL,
|
66
|
-
FOREIGN KEY fkey
|
66
|
+
FOREIGN KEY fkey4 (buys_id) REFERENCES buys(buys_id),
|
67
|
-
FOREIGN KEY fkey
|
67
|
+
FOREIGN KEY fkey5 (items_id) REFERENCES itemsinfo(items_id),
|
68
|
-
FOREIGN KEY fkey
|
68
|
+
FOREIGN KEY fkey6 (itemsinfo_size) REFERENCES itemsinfo(itemsinfo_size),
|
69
69
|
PRIMARY KEY(buys_id, items_id, itemsinfo_size)
|
70
70
|
);
|
71
71
|
```
|
1
xamppのphpmyadminで試した結果を補足情報に追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -79,3 +79,26 @@
|
|
79
79
|
|
80
80
|
lolipopのphpmyadminです。
|
81
81
|
|
82
|
+
xamppのphpmyadminで試した結果、次のエラーとログが出力されました。
|
83
|
+
```エラー
|
84
|
+
#1005 - `webdb`.`details` テーブルが作れません.(errno: 150 "Foreign key constraint is incorrectly formed")
|
85
|
+
```
|
86
|
+
```ログ
|
87
|
+
------------------------
|
88
|
+
LATEST FOREIGN KEY ERROR
|
89
|
+
------------------------
|
90
|
+
2022-10-29 14:11:39 0x3600 Error in foreign key constraint of table `webdb`.`details`:
|
91
|
+
FOREIGN KEY fkey6 (itemsinfo_size) REFERENCES itemsinfo(itemsinfo_size),
|
92
|
+
PRIMARY KEY(buys_id, items_id, itemsinfo_size)
|
93
|
+
):
|
94
|
+
Cannot find an index in the referenced table where the
|
95
|
+
referenced columns appear as the first columns, or column types
|
96
|
+
in the table and the referenced table do not match for constraint.
|
97
|
+
Note that the internal storage type of ENUM and SET changed in
|
98
|
+
tables created with >= InnoDB-4.1.12, and such columns in old tables
|
99
|
+
cannot be referenced by such columns in new tables.
|
100
|
+
Please refer to https://mariadb.com/kb/en/library/foreign-keys/ for correct foreign key definition.
|
101
|
+
Create table `webdb`.`details` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY fkey6 (itemsinfo_size) REFERENCES itemsinfo(itemsinfo_size),
|
102
|
+
PRIMARY KEY(buys_id, items_id, itemsinfo_size)
|
103
|
+
)'.
|
104
|
+
```
|