I am not able to create foreign key in mysql Error 150. Please help
- by Shantanu Gupta
i am trying to create a foreign key in my table. But when i executes my query it shows me error 150
Error Code : 1005 Can't create table
'.\vts#sql-6ec_1.frm' (errno: 150) (0
ms taken)
My Queries are
Query to create a foreign Key
alter table `vts`.`tblguardian` add constraint `FK_tblguardian` FOREIGN KEY (`GuardianPickPointId`) REFERENCES `tblpickpoint` (`PickPointId`)
Primary Key table
CREATE TABLE `tblpickpoint` (
`PickPointId` int(4) NOT NULL auto_increment,
`PickPointName` varchar(500) default NULL,
`PickPointLabel` varchar(500) default NULL,
`PickPointLatLong` varchar(100) NOT NULL,
PRIMARY KEY (`PickPointId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC
Foreign Key Table
CREATE TABLE `tblguardian` (
`GuardianId` int(4) NOT NULL auto_increment,
`GuardianName` varchar(500) default NULL,
`GuardianAddress` varchar(500) default NULL,
`GuardianMobilePrimary` varchar(15) NOT NULL,
`GuardianMobileSecondary` varchar(15) default NULL,
`GuardianPickPointId` varchar(100) default NULL,
PRIMARY KEY (`GuardianId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1