At 16:11 +0100 1/9/03, Rafal Jank wrote:
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?
Circular foreign key relationships? Removing the FOREIGN KEY
clause from the definition of pokoje allows the ALTER TABLE to work.
--
_/ _/ _/_/_/ ----- 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