I am not able to create foreign key in mysql Error 150. Please help

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-04-05T07:12:07Z Indexed on 2010/04/05 7:23 UTC
Read the original article Hit count: 330

Filed under:
|
|
|

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    

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database