Error Creating Foreign Key On Id Check Data Types
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might
Mysql Error Creating Foreign Key (check Data Types)
have Meta Discuss the workings and policies of this site About error creating foreign key on user_id (check data types) Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting
Error Creating Foreign Key Check Data Types Phpmyadmin
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million error creating foreign key on name (check data types) programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Error creating foreign key on
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error creating foreign key up vote 0 http://stackoverflow.com/questions/21711232/mysql-error-creating-foreign-key-on-columname-check-data-types down vote favorite I have been searching both SO and Google for this issue, but what i came up with was pretty much what my error message tells me and that's not the problem. I am using PHPMyAdmin to create relations between tables. I have this table "warehouse_product_history" with a column "from" of type int(11) NULL. I try to create a foreign key to the table "warehouses", http://stackoverflow.com/questions/14801458/error-creating-foreign-key and the query that PHPMyAdmin executes when doing so is the following ALTER TABLE `warehouse_product_history` ADD FOREIGN KEY (`from`) REFERENCES `my_db`.`warehouses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; The type of warehouses->id is int(11) NOT NULL, so that shouldn't be the problem. I've tried to change the datatype of the `from-column to int(11) NOT NULL but with the same result. I get this error message Error creating foreign key on from (check data types) mysql share|improve this question edited Feb 10 '13 at 19:41 asked Feb 10 '13 at 19:05 Anton Gildebrand 1,37063161 What specific error are you receiving? Are you receiving this on an existing populated table? Are both tables InnoDB? Have you run SHOW INNODB STATUS after trying to create the constraint? Are both columns identical? –Kermit Feb 10 '13 at 19:08 Updated the question with the error. The warehouse table is populated. warehouse_product_history isn't. I don't have permissions to show innodb status unfortunately. They are indeed identical. –Anton Gildebrand Feb 10 '13 at 19:50 Can you share the table schema for both, so that we can try? –SparKot Feb 10 '13 at 20:34 The tables can be fo
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Databases MySQL Help Setting up Foreign keys Thread: Setting up Foreign http://forums.devshed.com/mysql-help-4/setting-foreign-keys-520976.html keys Page 1 of 2 12 Last Jump to page: Share This Thread Tweet This + 1 this Post To Linkedin Subscribe to this Thread Subscribe to This Thread April 3rd, 2008,06:46 PM #1 msteudel View Profile View Forum Posts Visit Homepage Contributing User Devshed Novice (500 - 999 posts) Join Date Sep 2002 Location Seattle, foreign key U.S.A. Posts 715 Rep Power 15 Setting up Foreign keys Hi All, New to Foreign key stuff starting a new project and thought I would give it a whirl. I have two tables right now: users =========== id: int(10) email: varchar(255) cases =========== id: int(10) user_id: int(10) I want to create a foreign key from cases.user_id to the users.id. Both tables are InnoDB and error creating foreign I have created a index on user_id and I don't have any data in my tables. This is the code used to create the index: Code: ALTER TABLE `student_cases` ADD INDEX ( `user_id` ) WHen I try and create a foreign key using: Code: ALTER TABLE `student_cases` ADD FOREIGN KEY ( `user_id` ) REFERENCES `yah`.`users` ( `id` ) ON DELETE CASCADE ; I get the following error: Code: Error creating foreign key (check data types) : user_id * Note I'm using phpMyAdmin Thanks, Mark Faq Reply With Quote April 3rd, 2008,09:43 PM #2 r937 View Profile View Forum Posts Visit Homepage SQL Consultant Devshed Supreme Being (6500+ posts) Twitter Join Date Feb 2003 Location Toronto Canada Posts 27,591 Rep Power 4287 give us a hint the error message tells you it's a problem with the datatypes, but you haven't told us what the datatypes are rudy.ca | @rudydotca Buy my SitePoint book: Simply SQL Faq Reply With Quote April 4th, 2008,01:06 AM #3 msteudel View Profile View Forum Posts Visit Homepage Contributing Use