powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / MySQL [игнор отключен] [закрыт для гостей] / Внешние ключи
2 сообщений из 2, страница 1 из 1
Внешние ключи
    #32696244
vvHedgehog
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Вощем создаю таблицы в будующей БД-справочнике.
но на создании такой вот таблицы
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
CREATE TABLE IF NOT EXISTS 
   steel_analysis 
(
  ID             INT UNSIGNED NOT NULL PRIMARY KEY,
  Steel_ID    INT UNSIGNED,
  INDEX steel_ind (Steel_ID),
  FOREIGN KEY (Steel_ID) REFERENCES Steel(ID), 
  Element_ID  INT UNSIGNED,
  INDEX Element_ind (Element_ID),
  FOREIGN KEY (Element_ID) REFERENCES Сhemical_elements_ref(ID), 
  MinValue  DOUBLE,
  MaxValue DOUBLE,
  Comment  VARCHAR( 255 )
) TYPE = InnoDB;

ругается "типа key violation. не могу создать таблицу.... errno:150".
такие дела.
Таблицы Steel и Сhemical_elements_ref созданы . ID у всех таблиц как и в этой.
Что не так скажите пжлст!!!
...
Рейтинг: 0 / 0
Внешние ключи
    #32696364
Фотография Хрен
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Версия mysql меньше 4.1.2?

Кусок документации:
MySQL
If MySQL reports an error number 1005 from a CREATE TABLE statement, and the error message string refers to errno 150, this means that the table creation failed because a foreign key constraint was not correctly formed. Similarly, if an ALTER TABLE fails and it refers to errno 150, that means a foreign key definition would be incorrectly formed for the altered table. Starting from MySQL 4.0.13, you can use SHOW INNODB STATUS to display a detailed explanation of the latest InnoDB foreign key error in the server.


По русски говоря первым делом после этой ошибки посмотри show innodb status, чтобы определиться, где именно проблема. Но скорее всего что-то из

MySQL AB
Corresponding columns in the foreign key and the referenced key must have similar internal data types inside InnoDB so that they can be compared without a type conversion. The size and the signedness of integer types has to be the same. The length of string types need not be the same. If you specify a SET NULL action, make sure that you have not declared the columns in the child table as NOT NULL
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / MySQL [игнор отключен] [закрыт для гостей] / Внешние ключи
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]