Answer the question
In order to leave comments, you need to log in
#1005 - Can't create table '' (errno: 150)
Goodnight! Faced a problem, does not load backup!
Actually the error itself:
Ошибка
SQL-запрос:
CREATE TABLE `blogs` (
`id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`user_id` INT( 10 ) UNSIGNED NOT NULL ,
`ctg_id` SMALLINT( 5 ) UNSIGNED NOT NULL ,
`dt` DATETIME NOT NULL ,
`title` VARCHAR( 255 ) DEFAULT NULL ,
`content` TEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
KEY `blogusr` ( `user_id` ) ,
CONSTRAINT `blogusr` FOREIGN KEY ( `user_id` ) REFERENCES `users` ( `id` ) ON DELETE CASCADE
) ENGINE = INNODB AUTO_INCREMENT =14 /*!40101 DEFAULT CHARSET=utf8 */;
#1005 - Can't create table 'test.blogs' (errno: 150)
Answer the question
In order to leave comments, you need to log in
If the MySQL CREATE TABLE statement throws error number 1005, and there is a reference to error number 150 in the error message line, the table creation failed because the foreign key constraints were not properly formed.
from here - www.mysql.ru/docs/man/SEC451.html
Check that you have already created a table `users`, it has a field `users`.`id` INT( 10 ) UNSIGNED, this field is the primary key or an index is built on it, the database does not yet use the FK named ` user_id`, the `blogs` and `users` tables and the `blogs`.`user_id` and `users`.`id` fields have the same charset and collation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question