- Primärschlüssel ODER
- eine NOT NULL UNIQUE-Spalte, die als PK fungiert (InnoDB wählt sie automatisch aus)
Code: Select all
mysql> DESCRIBE tableA;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(20) | YES | UNI | NULL | |
+-------+--------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> DESCRIBE tableB;
+-------------+--------------+------+-----+-------------------+-------------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+-------------------+-------------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| tableA_id | int unsigned | NO | MUL | NULL | |
| col1 | varchar(10) | YES | | NULL | |
| col2 | text | YES | | NULL | |
| created | datetime | YES | | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
+-------------+--------------+------+-----+-------------------+-------------------+
5 rows in set (0.00 sec)
- Wenn ich Zeilen in Tabelle A einfüge, werden sie problemlos hinzugefügt.
- Wenn ich dann Zeilen in Tabelle B einfüge, wird der folgende Fehler ausgegeben
Code: Select all
ERROR 3098 (HY000):
The table does not comply with the requirements by an external plugin.
Code: Select all
CONSTRAINT `tableA_id_ibfk_1` FOREIGN KEY (`tableA_id`) REFERENCES `tableA` (`id`) ON DELETE CASCADE
Ich brauche den AUSLÄNDISCHEN SCHLÜSSEL ... irgendwelche Gedanken?
Mobile version