Questions tagged [mysql-error-150]
17 questions
169
votes
35 answers
MySQL: Can't create table (errno: 150)
I am trying to import a .sql file and its failing on creating tables.
Here's the query that fails:
CREATE TABLE `data` (
`id` int(10) unsigned NOT NULL,
`name` varchar(100) NOT NULL,
`value` varchar(15) NOT NULL,
UNIQUE KEY `id`…

gtilx
- 2,055
- 4
- 17
- 21
108
votes
20 answers
MySQL Creating tables with Foreign Keys giving errno: 150
I am trying to create a table in MySQL with two foreign keys, which reference the primary keys in 2 other tables, but I am getting an errno: 150 error and it will not create the table.
Here is the SQL for all 3 tables:
CREATE TABLE role_groups (
…
user176842
18
votes
7 answers
MySql Error 150 - Foreign keys
When I execute the follow two queries (I have stripped them down to absolutely necessary):
mysql> CREATE TABLE foo(id INT PRIMARY KEY);
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE bar ( id INT, ref INT, FOREIGN KEY (ref) REFERENCES…

Martin Thurau
- 7,564
- 7
- 43
- 80
3
votes
1 answer
Can't link two tables?
I'm sure this is something ridiculously simple, but I can't get my head around it.
Every time I try running this script, I get error number 150. I know that this is a foreign key issue. My other tables are fine and link to the projectregister table…

Malpa
- 33
- 2
2
votes
1 answer
Moving to MariaDB from MySQL - Foreign key constraint is incorrectly formed
I just updated my local dev environment that uses XAMPP and the new version of XAMPP uses MariaDB, whereas the old version I was on was using MySQL, which I'm fine with.
Now, I thought MariaDB was supposed to be fully compatible with MySQL as it's…

Brett
- 19,449
- 54
- 157
- 290
1
vote
1 answer
MySQL Create Table Statement Strange Errors
I am trying to run some basic CREATE TABLE statements for my Databases course project and am getting some strange errors.
When I create the table Manuf it runs fine, but when I try to create the next table, Order, using the same syntax, it does not…

Biggytiny
- 519
- 10
- 29
0
votes
1 answer
How to debug errno: 150 "Foreign key constraint is incorrectly formed" in Laravel?
Here I have three tables - customers | orders | services.
I am trying to add customers and services table's ID as foreign key in orders table, but getting an error while migrating as error 150. I'm a new learner of Laravel framework. How can I debug…

NM.Riyas
- 19
- 5
0
votes
3 answers
MySQL - Error: 150 "Foreign key constraint is incorrectly formed")
Got an odd problem I cant solve after browsing dozens of forum posts, and my local SQL Books.
I've got two tables, and want to add a foreign key to one of them. The foreign key and primary key share the same datatype and charset and yet I cannot add…

Wellendox
- 13
- 1
- 3
0
votes
1 answer
MySQL 150: Foreign key constraint is incorrectly formed
When I import the file to phpmyadmin I'm getting this err :
#1005 - Can't create table `test_db`.`part_order` (errno: 150
"Foreign key constraint is incorrectly formed")
I checked the syntax many times but I can't see what's wrong. I tried to…

selected
- 764
- 2
- 10
- 19
0
votes
1 answer
MySQL Error 1215 creating foreign key
My question is about MySQL, I keep getting an error (Error 1215: Cannot add Foreign key Constraint) while trying to forward engineer a schema to a db server, I've got two parent tables:
CREATE TABLE IF NOT EXISTS alunos (
idAluno INT NOT NULL…

Single
- 13
- 3
0
votes
2 answers
mysql error 150 from referencing same foreign key column in two tables
I have looked through quite a few posts but havent found the solution for my problem. My suspicion is the error stems from me trying to use a single column to reference the same primary key column in two different tables. Specifically the bid table…

german129
- 237
- 2
- 10
0
votes
2 answers
Error: 150 / MySQL 'Can't create table'
So I made a database model through the model creator in MySQL Workbench. However, I'm running into an error code when I try to convert it to an SQL file. The error says
Can't create table project2i2w.customer (error: 150 "Foreign key constraint is…

Nicholas Savory
- 25
- 1
- 7
0
votes
1 answer
error 150 creating table with mysql with foreign keys
I'm not really sure why i'm getting error 150 from phpmyadmin in my web-server, when i create the tables in local it works fine, maybe I'm missing something.
Here's my code:
Table usuarios
CREATE TABLE IF NOT EXISTS `usuarios` (
`id` INT NOT NULL…

Miguel Ramirez
- 83
- 2
- 14
0
votes
2 answers
MySQL Error 150 Can't assign Genre as a foreign key from the Genre table into Album table
I don't know why the error code keeps popping up. What i'm trying to do is set the Genre column in my Album table to a foreign key that links to the Genre column in the Genre Table. But every time I try to implement Genre as a foreign key in the SQL…

Henry Green
- 243
- 3
- 4
- 15
0
votes
1 answer
Error in MySQL on create statement
I have a doubt what I'm doing wrong with the following table statement:
MySQL returns error 150
DROP table usuario;
DROP table MiTabla;
CREATE TABLE usuario(
id smallint unsigned auto_increment primary key,
name varchar(20) not…

user2862454
- 1
- 5