简体   繁体   中英

Restoring old database in Mysql

I am trying to restore an old database (from 2009) using phpMyAdmin. I get the following error:

#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

I googled the error but couldn't find a solution. I understand something has changed with MySQL over years, but what should i do?

My query is as follows:

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;

You have multiple errors:

As has already been pointed out not_null should be not null . As well as primary_key should be primary key .

I changed string(xx) to varchar

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

real(xx) takes two arguments, not 1. The second argument is how many decimals places are after the decimal point.

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

type=MyISAM was changed to Engine=MyIsam

You also defined your primary key twice, once on the first line declaration and on the last line of the table declaration. I changed to this to declare it only once.

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 NULLPRIMARY KEY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM