PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
#1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

Réponse
 
LinkBack Outils de la discussion
Vieux 13/03/2008, 20h33   #1
Yves Goergen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

Hello,

I'm using MySQL 5.0 on Windows XP, with a few InnoDB tables and would
like to create a new foreign key constraint to one table.

Here's a simplified structure:

CREATE TABLE "message" (
"MessageId" INTEGER UNSIGNED NOT NULL PRIMARY KEY,
"Owner" INTEGER UNSIGNED NOT NULL,
"SearchRevision" INTEGER UNSIGNED)
ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';

CREATE TABLE "message_revision" (
"MessageId" INTEGER UNSIGNED NOT NULL,
"RevisionNumber" SMALLINT UNSIGNED NOT NULL,
"Author" INTEGER UNSIGNED NOT NULL,
PRIMARY KEY ("MessageId", "RevisionNumber"))
ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';

ALTER TABLE "message_revision" ADD FOREIGN KEY ("MessageId") REFERENCES
"message" ("MessageId") ON DELETE CASCADE;

This is all fine and I've put some data in the tables already. But all
data is valid and won't interfer with the following new constraint:

ALTER TABLE "message" ADD FOREIGN KEY ("MessageId", "SearchRevision")
REFERENCES "message_revision" ("MessageId", "RevisionNumber") ON DELETE
CASCADE;

Now the last command produces this error:

#1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

I've restarted the MySQL service but it doesn't . Is it broken? Why
is it trying to create some random table and why does that fail?

--
Yves Goergen "LonelyPixel" <nospam.list@unclassified.de>
Visit my web laboratory at http://beta.unclassified.de
  Réponse avec citation
Vieux 14/03/2008, 00h55   #2
Rob Wultsch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

On Thu, Mar 13, 2008 at 12:33 PM, Yves Goergen
<nospam.list@unclassified.de> wrote:

> CREATE TABLE "message" (
> "MessageId" INTEGER UNSIGNED NOT NULL PRIMARY KEY,
> "Owner" INTEGER UNSIGNED NOT NULL,
> "SearchRevision" INTEGER UNSIGNED)
> ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';
>
> CREATE TABLE "message_revision" (
> "MessageId" INTEGER UNSIGNED NOT NULL,
> "RevisionNumber" SMALLINT UNSIGNED NOT NULL,
> "Author" INTEGER UNSIGNED NOT NULL,
> PRIMARY KEY ("MessageId", "RevisionNumber"))
> ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';
>


> ALTER TABLE "message" ADD FOREIGN KEY ("MessageId", "SearchRevision")
> REFERENCES "message_revision" ("MessageId", "RevisionNumber") ON DELETE
> CASCADE;
>


> #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)



I am guessing it is an issue with "SearchRevision" being an INTEGER,
and "RevisionNumber" being a SMALLINT.

http://www.google.com/search?q=150+error+mysql yields
http://bugs.mysql.com/bug.php?id=6188 as it's first result.

"InnoDB does not give a clear error message if you try to create a
table with one or more
column types that do not match the column types of foriegn keys that
had been established
against that table."

--
Rob Wultsch
  Réponse avec citation
Vieux 14/03/2008, 13h14   #3
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

On Thu, Mar 13, 2008 at 7:55 PM, Rob Wultsch <wultsch@gmail.com> wrote:
> On Thu, Mar 13, 2008 at 12:33 PM, Yves Goergen
> <nospam.list@unclassified.de> wrote:
>
> > CREATE TABLE "message" (
> > "MessageId" INTEGER UNSIGNED NOT NULL PRIMARY KEY,
> > "Owner" INTEGER UNSIGNED NOT NULL,
> > "SearchRevision" INTEGER UNSIGNED)
> > ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';
> >
> > CREATE TABLE "message_revision" (
> > "MessageId" INTEGER UNSIGNED NOT NULL,
> > "RevisionNumber" SMALLINT UNSIGNED NOT NULL,
> > "Author" INTEGER UNSIGNED NOT NULL,
> > PRIMARY KEY ("MessageId", "RevisionNumber"))
> > ENGINE 'InnoDB' CHARACTER SET 'utf8' COLLATE 'utf8_bin';
> >

>
>
> > ALTER TABLE "message" ADD FOREIGN KEY ("MessageId", "SearchRevision")
> > REFERENCES "message_revision" ("MessageId", "RevisionNumber") ON DELETE
> > CASCADE;
> >

>
>
> > #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno: 150)

>
>
> I am guessing it is an issue with "SearchRevision" being an INTEGER,
> and "RevisionNumber" being a SMALLINT.


Yes, that's what is causing the trouble. But that's not all: the
UNSIGNED attribute has to match too. (It does in this case, but I'm
just pointing it out for future reference).
  Réponse avec citation
Vieux 15/03/2008, 22h20   #4
Yves Goergen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: #1005 - Can't create table '.\unb2test\#sql-770_2.frm' (errno:150)

On 14.03.2008 00:55 CE(S)T, Rob Wultsch wrote:
> I am guessing it is an issue with "SearchRevision" being an INTEGER,
> and "RevisionNumber" being a SMALLINT.


Thank you, that was the problem. My design was incorrect anyway to use
different types here... Now that's fixed, too.

> http://www.google.com/search?q=150+error+mysql yields
> http://bugs.mysql.com/bug.php?id=6188 as it's first result.


Not so in Germany. Also, I've searched for a more specific message.
Must have missed it.

--
Yves Goergen "LonelyPixel" <nospam.list@unclassified.de>
Visit my web laboratory at http://beta.unclassified.de
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h17.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19062 seconds with 12 queries