fightstarr20
fightstarr20

Reputation: 12598

mySQL import failing on DECIMAL

I am trying to import some fields into a MySQL database, here is my import file...

CREATE TABLE mytable(
 zip       VARCHAR(7) NOT NULL PRIMARY KEY
,lat       DECIMAL(10,8) NOT NULL
,long      DECIMAL(11,8) NOT NULL
,data      VARCHAR(3) NOT NULL
);

It is giving me the following error...

check the manual that corresponds to your MySQL server version for the right syntax to use near 'long DECIMAL(11,8) NOT NULL ,data VARCHAR(3) NOT NULL )' at line 4

It is not liking the long field that I am trying to set as DECIMAL type

Where am I going wrong?

Upvotes: 0

Views: 162

Answers (1)

shybovycha
shybovycha

Reputation: 12245

The long is the reserved keyword in MySQL. Try using escaping like this:

CREATE TABLE mytable
(zip       VARCHAR(7) NOT NULL PRIMARY KEY
,lat       DECIMAL(10,8) NOT NULL
,`long`    DECIMAL(11,8) NOT NULL
,data      VARCHAR(3) NOT NULL
);

Or, what is better, try using another name. For latitude and longitude this might be lat and lng or lat and lon.

Upvotes: 3

Related Questions