>Description: In CREATE TABLE, column-spec REFERENCES does nothing, as described in the documentation.
If FOREIGN KEY (x) REFERENCES othertable(y) is added to the table, as described in the documentation: http://www.mysql.com/doc/S/E/SEC446.html I always get an error like this: ERROR 1005 at line 23: Can't create table './MP3c/xtracks.frm' (errno: 150) I can create the table without FOREIGN KEY restraints. If I try to add them via ALTER TABLE, I get: ERROR 1005 at line 35: Can't create table './MP3c/#sql-8c1_e.frm' (errno: 150) The referred to keys are the same type and are indexed (they are primary keys). The only difference is that they are AUTO_INCREMENT, but even without AUTO_INCREMENT, the same problem occurs. Wiping out the entire InnoDB database and restarting does not make a difference, since the above page says that recreating tables with the same name can be a problem. I've also tried changing the database name and table name, to rule out any previous definitions that might be lying around. >How-To-Repeat: CREATE TABLE artists ( artist_id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, artist VARCHAR (32) NOT NULL UNIQUE ) type=InnoDB; CREATE TABLE albums ( album_id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, album VARCHAR (32) NOT NULL, year YEAR ) type=InnoDB; CREATE INDEX by_album ON albums(album); CREATE TABLE genres ( genre_id SMALLINT NOT NULL PRIMARY KEY, genre VARCHAR (32) NOT NULL ) type=InnoDB; CREATE TABLE tracks ( track_id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, artist_id INTEGER UNSIGNED NOT NULL, album_id INTEGER UNSIGNED NOT NULL, track SMALLINT, title VARCHAR (32) NOT NULL, genre_id SMALLINT, comment VARCHAR (32) NOT NULL DEFAULT '', filename VARCHAR (255) NOT NULL, FOREIGN KEY (artist_id) REFERENCES artists(artist_id), FOREIGN KEY (album_id) REFERENCES albums(album_id), FOREIGN KEY (genre_id) REFERENCES genres(genre_id) ) type=InnoDB; CREATE UNIQUE INDEX album_tracks ON tracks(album_id, track); CREATE INDEX by_title ON tracks(title); >Fix: Postgre^H^H^H^H^H^H^HNone. >Submitter-Id: <submitter ID> >Originator: Andy Dustman >Organization: > >MySQL support: none >Synopsis: FOREIGN KEYS don't work >Severity: serious >Priority: medium >Category: mysql >Class: sw-bug >Release: mysql-3.23.51 (Official MySQL RPM) >Environment: System: Linux 4.0.0.10.in-addr.arpa 2.4.18 #2 Tue May 28 17:55:48 EDT 2002 i686 unknown Architecture: i686 Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) Compilation info: CC='gcc' CFLAGS='-O6 -fno-omit-frame-pointer -mpentium' CXX='gcc' CXXFLAGS='-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' LDFLAGS='' LIBC: lrwxrwxrwx 1 root root 13 May 7 17:53 /lib/libc.so.6 -> libc-2.2.5.so -rwxr-xr-x 1 root root 1260480 Apr 15 09:44 /lib/libc-2.2.5.so -rw-r--r-- 1 root root 2310808 Apr 15 10:02 /usr/lib/libc.a -rw-r--r-- 1 root root 178 Apr 15 09:55 /usr/lib/libc.so Configure command: ./configure --disable-shared --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-other-libc=/usr/local/mysql-glibc --without-berkeley-db --without-innodb --enable-assembler --enable-local-infile --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/ --with-extra-charsets=complex --exec-prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/info --includedir=/usr/include --mandir=/usr/man '--with-comment=Official MySQL RPM' CC=gcc 'CFLAGS=-O6 -fno-omit-frame-pointer -mpentium' 'CXXFLAGS=-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' CXX=gcc --------------------------------------------------------------------- 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