ED]
> Sent: Tuesday, June 03, 2003 10:09 AM
> To: Justin Scheiber
> Cc: [EMAIL PROTECTED]
> Subject: Re: help creating foreign keys
>
> the syntax for foreign key creation is different than what you have. You
> need an alter table statement.
>
> create table bar (
oo_id),
foreign key (foo_id) references foo (foo_id)
) type=innodb;
-Original Message-
From: Jeff Mathis [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 03, 2003 10:09 AM
To: Justin Scheiber
Cc: [EMAIL PROTECTED]
Subject: Re: help creating foreign keys
the syntax for foreign key creati
the syntax for foreign key creation is different than what you have. You
need an alter table statement.
create table bar (
bar_idint unsigned auto_increment primary key,
foo_idint unsigned,
bar_value int,
) type=innodb;
alter table bar add constraint foreign key (foo_id) referen
Read the Foreign Key section of the InnoDB manual
(http://innodb.com/ibman.html#InnoDB_foreign_keys): it explains why you may get
an error code 150. Particularly:
Both tables have to be InnoDB type and there must be an index where the
foreign key and the referenced key are listed as the