Восстановление старой базы данных в Mysql

Я пытаюсь восстановить старую базу данных (с 2009 года), используя phpMyAdmin. Я получаю следующую ошибку:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not_null primary_key auto_increment, `Owned` int(11) not_null, `Owner` int' at line 2

Я погуглил ошибку, но не смог найти решение. Я понимаю, что с MySQL что-то изменилось за многие годы, но что мне делать?

Мой запрос выглядит следующим образом:

CREATE TABLE `aautod` (
    `aAutoId` int(11) not_null primary_key auto_increment, 
    `Owned` int(11) not_null, 
    `Owner` int(11) not_null, 
    `Description` string(64) not_null, 
    `Model` int(11) not_null, 
    `Value` int(11) not_null, 
    `Locked` int(11) not_null, 
    `ColorOne` int(11) not_null, 
    `ColorTwo` int(11) not_null, 
    `License` string(100) not_null, 
    `Locationx` real(12) not_null, 
    `Locationy` real(12) not_null, 
    `Locationz` real(12) not_null, 
    `Angle` real(12) not_null, 
    `Parked` real(12) not_null, 
    `ParkLocationx` real(12) not_null, 
    `ParkLocationy` real(12) not_null, 
    `ParkLocationz` real(12) not_null, 
    `ParkAngle` real(12) not_null, 
    `GPS` int(11) not_null, 
    `Color1` int(11) not_null, 
    `Color2` int(11) not_nul, 
    PRIMARY KEY (`aAutoId`)
) TYPE=MyISAM DEFAULT CHARSET=latin1;

2 ответа

Решение

У вас есть несколько ошибок:

Как уже было указано not_null должно быть not null, Так же как primary_key должно быть primary key,

Я изменился string(xx) в varchar

http://dev.mysql.com/doc/refman/5.5/en//string-types.html

real(xx) принимает два аргумента, а не 1. Второй аргумент - это количество знаков после запятой после десятичной точки.

http://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html

type=MyISAM был изменен на Engine=MyIsam

Вы также определили свой первичный ключ дважды, один раз в объявлении первой строки и в последней строке объявления таблицы. Я изменил это, чтобы объявить об этом только один раз.

CREATE TABLE `aautod` (
`aAutoId` int(11) not null primary key auto_increment, 
`Owned` int(11) not null, 
`Owner` int(11) not null, 
`Description` varchar(64) not null, 
`Model` int(11) not null, 
`Value` int(11) not null, 
`Locked` int(11) not null, 
`ColorOne` int(11) not null, 
`ColorTwo` int(11) not null, 
`License` varchar(100) not null, 
`Locationx` real(12,11) not null, 
`Locationy` real(12,11) not null, 
`Locationz` real(12,11) not null, 
`Angle` real(12,11) not null, 
`Parked` real(12,11) not null, 
`ParkLocationx` real(12,11) not null, 
`ParkLocationy` real(12, 11) not null, 
`ParkLocationz` real(12, 11) not null, 
`ParkAngle` real(12, 11) not null, 
`GPS` int(11) not null, 
`Color1` int(11) not null, 
`Color2` int(11) not null
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Это должны быть два отдельных слова: NOT NULL, PRIMARY KEY,

Другие вопросы по тегам