tab3.cod2 is not the first field in an index.

-- 

On Mon, 24 Mar 2003, Luis Matos Lima wrote:

> The thing his i already have created the first field 
> in an index on other tables. I write this:
> 
> CREATE TABLE tab1 (
>   Cod1 int(3) NOT NULL default '0',
>   PRIMARY KEY  (Cod1)
> )TYPE=INNODB;
> 
> CREATE TABLE tab2 (
>   Cod2 int(3) NOT NULL default '0',
>   PRIMARY KEY  (Cod2)
> )TYPE=INNODB;
> 
> CREATE TABLE tab3 (
>   cod1 int(3) NOT NULL ,
>   cod2 int(3) NOT NULL ,
>   PRIMARY KEY  (cod1,cod2),
>   FOREIGN KEY (cod1) REFERENCES tab1(cod1) 
> ON UPDATE CASCADE ON DELETE CASCADE,
>   FOREIGN KEY (cod2) REFERENCES tab2(cod2) 
> ON UPDATE CASCADE ON DELETE CASCADE)TYPE=INNODB
> 
> Then appears this:
> 
> CREATE TABLE tab3( 
> cod1 int( 3 ) NOT NULL ,
> cod2 int( 3 ) NOT NULL ,
> PRIMARY KEY ( cod1, cod2 ) ,
> FOREIGN KEY ( cod1 ) REFERENCES tab1( cod1 ) ON UPDATE 
> CASCADE ON DELETE CASCADE ,
> FOREIGN KEY ( cod2 ) REFERENCES tab2( cod2 ) ON UPDATE 
> CASCADE ON DELETE CASCADE 
> ) TYPE = INNODB 
> 
> Mensagens do MySQL : 
> Can't create table '.\test\tab3.frm' (errno: 150)
> 
> Luis
> 
> 
> Cópia Ernie Hershey <[EMAIL PROTECTED]>:
> 
> > In 3.23, all foreign keys must be on columns
> > that exist as the 
> > first field in an index on the table. This
> > applies to 
> > the columns they reference as well.
> > 
> > Ernie Hershey
> > 
> > -- 
> > 
> > On Mon, 24 Mar 2003, Luis Matos Lima wrote:
> > 
> > > i´m having some trouble in creating a table
> > like this 
> > > one.
> > > 
> > > CREATE TABLE tab3( 
> > > cod1 int( 3 ) NOT NULL ,
> > > cod2 int( 3 ) NOT NULL ,
> > > PRIMARY KEY ( cod1, cod2 ) ,
> > > FOREIGN KEY ( cod1 ) REFERENCES tab1( cod1 )
> > ON UPDATE 
> > > CASCADE ON DELETE CASCADE ,
> > > FOREIGN KEY ( cod2 ) REFERENCES tab2( cod2 )
> > ON UPDATE 
> > > CASCADE ON DELETE CASCADE 
> > > ) TYPE = INNODB 
> > > 
> > > I don´t understand why i acannot create it.
> > > I´m using mysql 4.0.12 in win98 wiht
> > phpmyadmin 2.2.4
> > > i receive a message error like this
> > > 
> > > Mensagens do MySQL : 
> > > Can't create table '.\test\tab3.frm' (errno:
> > 150)
> > > 
> > > Please help, i´m in a important project and i
> > need to 
> > > know how to slove this problem.
> > > 
> > > 
> > > 
> > > 
> > >
> > -------------------------------------------------
> > > Email Enviado utilizando o serviço MegaMail
> > > 
> > > 
> > 
> > 
> 
> 
> -------------------------------------------------
> Email Enviado utilizando o serviço MegaMail
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to