For several hours I have been solving a "banal" problem with creating two simplest tables and connecting them using InnoDB .
This time was enough to hate this technology.
And so the code is:
CREATE database thraph; USE thraph; CREATE TABLE `userdata` ( u_id INT NOT NULL AUTO_INCREMENT, username VARCHAR (16) NOT NULL, password VARCHAR (40) NOT NULL, email VARCHAR (40) NOT NULL, PRIMARY KEY(u_id) ) ENGINE = InnoDB; CREATE TABLE `ect` ( u_id INT UNSIGNED NOT NULL, u_group VARCHAR(6) NOT NULL, u_year VARCHAR(6) NOT NULL, PRIMARY KEY (u_id), FOREIGN KEY (u_id) REFERENCES userdata(u_id) ON UPDATE RESTRICT ON DELETE CASCADE ) ENGINE = InnoDB; When I try to execute scripts to create table ect , an error constantly crashes.
#1005 - Can't create table 'thraph.ect' (errno: 150) - Foreign key constraint is incorrectly formed And even if you manage to create a query and create a table, it is not filled. I only know:
Если оператор MySQL CREATE TABLE выдает ошибку с номером 1005, и в строке сообщения об ошибке присутствует ссылка на ошибку с номером 150, то произошел сбой создания таблицы из-за того, что ограничения внешнего ключа не были сформированы надлежащим образом. What does it mean properly? Why is there nothing intelligible on the Internet about this ... What is the way he does not like it)
I would be grateful if you at least partially solve my problem.
userdata(and FOREIGN KEY (u_id) REFERENCES user_data (u_id) Is this not ochepyatka? - mantigatos