Error No : 1005
Error Type : Server Error
Error Code : 1005 SQLSTATE: HY000 (ER_CANT_CREATE_TABLE)
Error Message : Can't create table '%s' (errno: %d)
This error may occur when you are trying to create a table and it fails.
There are many reasons that may cause this issue.
One of the reason is related to Foreign Key constraint that is not formed correctly (Error code 150).
MySQL QueryLanguage: SQL
CREATE TABLE `prog_lang` (
`lang_id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`lang_name` VARCHAR(100) NOT NULL,
`lang_desc` VARCHAR(255) NOT NULL,
`active_stat` CHAR(1)
);
CREATE TABLE `topic` (
`topic_id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`topic_desc` TEXT NOT NULL,
`lang_id` INT NOT NULL,
CONSTRAINT `fk_prog_lang` FOREIGN KEY(`lang_id`) REFERENCES `prog_lang`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Make sure that Engine and CHARSET of the tables match: ENGINE=InnoDB DEFAULT CHARSET=utf8.
This is not an AI-generated article but is demonstrated by a human.
Please support independent contributors like Code2care by donating a coffee.
Buy me a coffee!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!