LINUX.ORG.RU

MySQL, ошибка 150.

 


0

1

Люди, помогите, пожалуйста. Проблема непосредственно с MySQL. Создаю две таблицы. Первая создается нормально, а вторая — с популярной ошибкой. Перепробовал много вариантов решения проблемы — не помог ни один.

create table movies_main (
id int auto_increment not null,
f_id int (5) not null,
name_ru varchar (80) not null,
name_eng varchar (80) not null,
duration int (3) not null,
direct_id int (4),
actchar_id int (4) not null,
screenwr_id int (4) not null,
prod_id int (4) not null,
country_id int (2) not null,
year_id int (3) not null,
genre int (3) not null,
award_id int (3) not null,
about_id int (4) not null,
primary key (id)
);
 
--------------------------------------------------
--
--------------------------------------------------     
create table directs (
id int auto_increment not null,
di_id int (4),
director varchar (80) not null,
primary key (id),
foreign key (di_id) references movies_main (direct_id)
);
 
--------------ошибка
 
MariaDB [moviebase]> create table directs (
id int auto_increment not null,
di_id int (4),
director varchar (80) not null,
primary key (id),
foreign key (di_id) references movies_main (direct_id)
);
ERROR 1005 (HY000): Can not create table 'moviebase.directs' (errno: 150)
MariaDB [moviebase]>

Все, что было тут — не подходит: http://www.sql.ru/forum/626099/preslovutaya-oshibka-errno-150 Все, что было тут — тоже: http://stackoverflow.com/questions/11045279/error-1005-hy000-cant-create-tabl...

ЧЯДНТ?



Последнее исправление: linuxedhorse (всего исправлений: 2)

Ответ на: комментарий от goingUp

Да, помогло. Добавил индексы и ошибка ушла. Спасибо.

linuxedhorse
() автор топика
Ответ на: комментарий от linuxedhorse

Это не количество цифр после нулей. На длину числа оно не влияет, только на то, как оно будет отображаться в консольном клиенте.

goingUp ★★★★★
()
Ответ на: комментарий от anonymous

Сделай лицо попроще, открой мануал и прочитай, что это display width

goingUp ★★★★★
()

direct_id int (4) в таблице должен быть с уникальным индексом.

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.