Hello,
I have two tables, here are the 'show create' statements for them:
I'm trying to create a foreign key on useractskills for skilltype, skillid and dept:
But this fails:
ERROR 1005 (HY000): Can't create table './dbspd/#sql-8b6_51.frm' (errno: 150)
The only references I can find about this are that the fields have to be indexed (which they are), the types have to be the same across the tables (which they are) and you don't break any NOT NULL constraints using SET NULL (which I don't).
Does anyone know what the problem is?
C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
I have two tables, here are the 'show create' statements for them:
Code:
CREATE TABLE `useractskills` (
`username` varchar(20) NOT NULL default '',
`skilltype` int(11) NOT NULL default '0',
`skillid` int(11) NOT NULL default '0',
`dept` varchar(20) NOT NULL default '',
KEY `xusername` (`username`),
KEY `xskills` (`skilltype`,`skillid`,`dept`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `skills` (
`skilltype` int(11) NOT NULL default '0',
`id` int(11) NOT NULL default '0',
`dept` varchar(20) NOT NULL default '',
`name` text,
`description` text,
`details` text,
KEY `xdept` (`dept`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
I'm trying to create a foreign key on useractskills for skilltype, skillid and dept:
Code:
ALTER TABLE useractskills ADD FOREIGN KEY `FK_skills` (`skilltype`, `skillid`, `dept`)
REFERENCES `skills` (`skilltype`, `id`, `dept`)
ON DELETE NO ACTION
ON UPDATE CASCADE;
But this fails:
ERROR 1005 (HY000): Can't create table './dbspd/#sql-8b6_51.frm' (errno: 150)
The only references I can find about this are that the fields have to be indexed (which they are), the types have to be the same across the tables (which they are) and you don't break any NOT NULL constraints using SET NULL (which I don't).
Does anyone know what the problem is?
C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!