MySQL Forums
Forum List  »  InnoDB

ERROR 1005 (HY000): Can't create table
Posted by: Mohsen Sayrafy
Date: September 04, 2007 02:00PM

Hallo,
ich habe ein DB namens „libraray1“ und einige Tabellen erzeugt. Dann wollte ich die Eigenschaft der Tabellen ändert. Deshalb habe ich folgenden Code geschrieben:

mysql> DROP DATABASE IF EXISTS `library1`;
Query OK, 2 rows affected (0.08 sec)

mysql> CREATE DATABASE `library1`;
Query OK, 1 row affected (0.00 sec)

mysql> DROP TABLE IF EXISTS `library1`.`s040-artisttype`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE `library1`.`s040-artisttype` (
-> `ID` tinyint(4) unsigned NOT NULL auto_increment,
-> `TYPE` varchar(255) NOT NULL,
-> PRIMARY KEY USING BTREE (`ID`),
-> UNIQUE KEY `UNIQUE_TYPE` USING BTREE (`TYPE`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ERROR 1005 (HY000): Can't create table '.\library1\s040-artisttype.frm' (errno: 150)

Ich habe versucht, mit der Kommandos „SHOW INNODB STATUS;“ die Fehler genauer zu finden. Dann habe ich folgendes erhalten:

mysql> SHOW INNODB STATUS;
………
LATEST FOREIGN KEY ERROR
------------------------
070901 19:46:03 Error in foreign key constraint of table library1/s240-spielfilme_kuenstler:
there is no index in referenced table which would contain
the columns as the first columns, or the data types in the
referenced table do not match to the ones in table. Constraint:
,
CONSTRAINT FK_spielfilme_kuenstler_KUNSTLERTYPEID FOREIGN KEY (ARTISTTYPE_ID) REFERENCES s040-artisttype (ARTISTTYPE_ID) ON UPDATE CASCADE
..........

Aber es gibt keine Tabelle mehr mit dem Namen „s240-spielfilme_kuenstler“ und keine CONSTRAINT mit dem Namen „FK_spielfilme_kuenstler_KUNST“.
Die Fehlermeldung bedeutet, wenn ich statt der Spalte „ID“ die Spalte „ARTISTTYPE_ID“ in der Tabelle „s040-artisttype“ einsetze, gibt es dann keine Fehler mehr:

DROP TABLE IF EXISTS `library1`.`s040-artisttype`;
CREATE TABLE `library1`.`s040-artisttype` (
`ARTISTTYPE_ID` tinyint(4) unsigned NOT NULL auto_increment,
`TYPE` varchar(255) NOT NULL,
PRIMARY KEY USING BTREE (`ARTISTTYPE_ID`),
UNIQUE KEY `UNIQUE_KUENSTLERTYPENAME_kuenstlertype` USING BTREE (`TYPE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Query OK, …..
Ich habe auch im Manual folgendes gelesen:
„If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns error number 1005 and refers to errno 150 in the error message.“
Aber wie ich gesagt habe, gibt es mehr kein Tabelle „s240-spielfilme_kuenstler“ mehr und ich will sie nicht später erzeugen.
Ist das ein Debug oder ist das normal? Wie kann ich das Problem beseitigen.

Viele Grüße
Mohsen

Options: ReplyQuote


Subject
Views
Written By
Posted
ERROR 1005 (HY000): Can't create table
8233
September 04, 2007 02:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.