Voglio creare un riferimento alla tabella esterna. ma sto ottenendo il seguente errore:Impossibile risolvere il nome della tabella vicino a
query:
CREATE TABLE category_ids (id INT, post_id INT,
INDEX par_ind (post_id),
FOREIGN KEY (post_id) REFERENCES post(id)
ON DELETE CASCADE
) ENGINE=INNODB;
MOSTRA motore InnoDB STATUS \ G:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2013-08-23 00:11:06 7f6f49e7b700 Error in foreign key constraint of table fun/category_ids:
FOREIGN KEY (post_id) REFERENCES post(id)
ON DELETE CASCADE
) ENGINE=INNODB:
Cannot resolve table name close to:
(id)
ON DELETE CASCADE
) ENGINE=INNODB
struttura
messaggi tabella
mysql> describe post;
+-------------+-----------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------------------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
...
+-------------+-----------------------+------+-----+---------------------+----------------+
22 rows in set (0.00 sec)
Probabilmente pensa che "post" sia una parola riservata, cosa succede se si qualifica il post nella chiave esterna con i tick posteriori (ad esempio \ "post \" (id)). –
Hai qualche modo per controllare che le tue tabelle stiano usando correttamente INNODB e non qualcos'altro? (Anche se l'hai scritto chiaramente, sì) – Sugar
Puoi usare 'SHOW CREATE TABLE' per controllare il motore usato per la tabella di riferimento. – deltab