Rafal, > alter table rezerwacje add foreign key (nip_h,nrpok_p) references > pokoje(nip_h,nrpok_p);
> ERROR 1005: Can't create table './test/#sql-932_4.frm' (errno: 150) Most probably, you are using MySQL >= 4.0.1 but < 4.0.5. I had these kind of problems with ALTER TABLE with 4.0.1 and 4.0.4, but not with 4.0.7 anymore (hey, this rhymes :). I guess it has nothing to do with the foreign keys, but with the temporary form table MySQL creates when you do an ALTER TABLE. Anyway, the problem seems to be fixed, so you should update to >= 4.0.7. Regards, -- Stefan Hinz <[EMAIL PROTECTED]> Geschäftsführer / CEO iConnect GmbH <http://iConnect.de> Heesestr. 6, 12169 Berlin (Germany) Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 ----- Original Message ----- From: "Rafal Jank" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 09, 2003 4:11 PM Subject: Bug in foreign keys > Hi! > I have two tables: > CREATE TABLE `pokoje` ( > `nrpok_p` char(10) NOT NULL default '', > `nip_h` int(10) NOT NULL default '0', > `lozka_p` char(2) default NULL, > `tv_p` char(1) default NULL, > `lazienka_p` char(1) default NULL, > `cena_p` int(10) default NULL, > `zaliczka_p` int(10) default NULL, > PRIMARY KEY (`nrpok_p`,`nip_h`), > KEY `nip_h_index` (`nip_h`,`nrpok_p`), > FOREIGN KEY (`nip_h`) REFERENCES `hotele` (`nip_h`) ON DELETE CASCADE > ) TYPE=InnoDB; > > CREATE TABLE `rezerwacje` ( > `id_r` int(10) NOT NULL default '0', > `pesel_k` int(11) default NULL, > `nip_h` int(10) NOT NULL default '0', > `nrpok_p` char(10) NOT NULL default '', > `data_r` date default NULL, > `od_r` date default NULL, > `do_r` date default NULL, > `cena_r` int(10) default NULL, > `zaliczka_r` int(5) default NULL, > `zaplac_r` char(1) default NULL, > `wplaczal_r` char(1) default NULL, > PRIMARY KEY (`id_r`), > KEY `nip_h_index` (`nip_h`,`nrpok_p`) > ) TYPE=InnoDB; > > Now, when I try: > alter table rezerwacje add foreign key (nip_h,nrpok_p) references > pokoje(nip_h,nrpok_p); > I get: > ERROR 1005: Can't create table './test/#sql-932_4.frm' (errno: 150) > > Why? > > > > -- > _/ _/ _/_/_/ ----- Rafał Jank [EMAIL PROTECTED] ----- > _/ _/ _/ _/ _/ Wirtualna Polska SA http://www.wp.pl > _/_/_/_/ _/_/_/ ul. Traugutta 115c, 80-237 Gdansk, tel/fax. (58)5215625 > _/ _/ _/ --------==* http://szukaj.wp.pl *==---------- > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php