Bug #51589 ERROR 1064 (42000)
Submitted: 28 Feb 2010 17:07 Modified: 1 Apr 2010 11:41
Reporter: mamatha hl Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Data Types Severity:S2 (Serious)
Version:5.0.67 OS:Any
Assigned to: CPU Architecture:Any
Tags: #1064, 10), decimal(15, error, syantax

[28 Feb 2010 17:07] mamatha hl
Description:
I'm trying to make a clone of the existing table. When I give the following,
create table `clone_loc` (
    ->  `id` int(11) NOT NULL auto_increment,
    ->   `lat` decimal(15,10) default NULL,
    ->   `lng` decimal(15,10) default NULL,
    ->   `address` text collate utf8_unicode_ci,
    ->   `city` varchar(255) collate utf8_unicode_ci default NULL,
    ->   `state` varchar(255) collate utf8_unicode_ci default NULL,
    ->   `country` varchar(255) collate utf8_unicode_ci default NULL,
    ->   `pincode` varchar(255) collate utf8_unicode_ci default NULL,
    ->   `created_at` datetime default NULL,
    ->   `updated_at` datetime default NULL,
    ->   PRIMARY KEY  (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=2017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
    -> ;
The below error is given:- 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 '->   `lat` decimal(15,10) default NULL,
    ->   `lng` decimal(15,10) default NU' at line 3

How to repeat:
Kindly help me in finding a solution to this error.
[28 Feb 2010 17:50] Valeriy Kravchuk
What exact version, 5.x.y, do you use? Look, CREATE works for me:

77-52-24-143:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.45-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table `clone_loc` (
    -> `id` int(11) NOT NULL auto_increment,
    -> `lat` decimal(15,10) default NULL,
    -> `lng` decimal(15,10) default NULL,
    -> `address` text collate utf8_unicode_ci,
    -> `city` varchar(255) collate utf8_unicode_ci default NULL,
    -> `state` varchar(255) collate utf8_unicode_ci default NULL,
    -> `country` varchar(255) collate utf8_unicode_ci default NULL,
    -> `pincode` varchar(255) collate utf8_unicode_ci default NULL,
    -> `created_at` datetime default NULL,
    -> `updated_at` datetime default NULL,
    -> PRIMARY KEY  (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=2017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.12 sec)
[28 Feb 2010 18:20] mamatha hl
I use 5.0.67 version.  Is decimal(15,10) not allowed in this version?
[28 Feb 2010 18:39] Valeriy Kravchuk
No, the syntax is valid for 5.0.x also:

77-52-24-143:5.0 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.91-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table `clone_loc` (
    -> `id` int(11) NOT NULL auto_increment,
    -> `lat` decimal(15,10) default NULL,
    -> `lng` decimal(15,10) default NULL,
    -> `address` text collate utf8_unicode_ci,
    -> `city` varchar(255) collate utf8_unicode_ci default NULL,
    -> `state` varchar(255) collate utf8_unicode_ci default NULL,
    -> `country` varchar(255) collate utf8_unicode_ci default NULL,
    -> `pincode` varchar(255) collate utf8_unicode_ci default NULL,
    -> `created_at` datetime default NULL,
    -> `updated_at` datetime default NULL,
    -> PRIMARY KEY  (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=2017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.03 sec)

Maybe you had some TAB characters or something else before `lat`. Please, double check. And yes, I'd recommend to upgrade to newer 5.0.x version, 5.0.90, in any case.
[28 Feb 2010 23:39] mamatha hl
I dont think there is anything wrong with the syntax.  I first executed show create table locations(my original source table).  Then I just typed create table `clone_loc` and copy pasted all the fields and their datatypes from the output of the show create table locations.  I'm quite sure it has got something to do with this decimal(15,10) because I was successful in creating clone of other tables which did not have any data type mentioned as decimal(15,10).  So, still my problem is unresolved.
[1 Mar 2010 4:24] Valeriy Kravchuk
As you can see from my examples, your problem is NOT repeatable with recent versions of MySQL. Had you tried to check with 5.0.90?
[1 Mar 2010 10:03] mamatha hl
Ok. I'll try doing it with 5.0.90 now.
[1 Mar 2010 11:41] Valeriy Kravchuk
Please, inform about the results.
[1 Apr 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".