Good day, comrades! Help me figure it out, please. I started learning the MySQL DBMS, I found literature, all that .. But one example cannot even be repeated. Here it is before my eyes, but it does not work on the machine. Here is the code:

-- Создание индекса при создании таблицы DROP TABLE IF EXISTS table5; CREATE TABLE table5 ( id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Код товара', code CHAR(4) NOT NULL DEFAULT 'AAAA' COMMENT 'Код товара', name VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Название товара', price FLOAT NOT NULL DEFAULT 0 COMMENT 'Цена товара', CONSTRAINT pkId PRIMARY KEY (id), CONSTRAINT ixCode UNIQUE KEY (code), INDEX ixName (name), INDEX ixPrice (price) 

) COMMENT 'Table of goods with a key and indexes';

 -- Создание таблицы с ВНЕШНИМ индексом DROP TABLE IF EXISTS table6_child; CREATE TABLE table6_child ( id INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Код записи', code CHAR(4) NOT NULL DEFAULT 'AAAA' COMMENT 'Код товара', quo FLOAT NOT NULL DEFAULT 0 COMMENT 'Приход/расход товара', CONSTRAINT pkId PRIMARY KEY (id), INDEX ixCode (code), CONSTRAINT fkTable5Code FOREIGN KEY (code) REFERENCES teble5 (code) ); 

Does not create a beast overseas second table! Gives the answer in the form:

 ERROR 1005 (HY000): Can't create table 'modul3.table6_child' (errno: 150) 

The InnoDB engine stands, is active .. The data type in the key column is apparently the same .. I will be grateful for the help.

    1 answer 1

    teble5 can be table5.

    • Thank you very much! Errors in inattention - the most nasty, especially if the language is new. PS Cool nickname :) - Dmitry Blinnikov
    • one
      Zhmakni plus sign if it helped - LAST