简体   繁体   中英

ALTER TABLE table_name AUTO_INCREMENT = 1000; gives me syntax error

this is my table export:

CREATE TABLE IF NOT EXISTS `order` (

  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `comment` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

  `shipping_cost` double DEFAULT NULL,

  `customer_id` int(11) NOT NULL,

  `delivery_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,

  `invoice_nr` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,

  `created_at` timestamp NULL DEFAULT NULL,

  `updated_at` timestamp NULL DEFAULT NULL,

  `deleted_at` timestamp NULL DEFAULT NULL,

  PRIMARY KEY (`id`),

  KEY `order_customer_id_index` (`customer_id`),

  KEY `order_invoice_nr_index` (`invoice_nr`),

  KEY `order_created_at_index` (`created_at`),

  KEY `order_updated_at_index` (`updated_at`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

when I run now:

ALTER TABLE order AUTO_INCREMENT=1000;

I get:

#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 'order AUTO_INCREMENT=1000' at line 1

the table is empty!

mysql version: 5.5.44-0ubuntu0.14.04.1

someone has an idea what could cause me this problem?

if I put for example this:

ALTER TABLE asdasdfasdfasdf AUTO_INCREMENT=1000;

I get

1146 - Table 'mydb.asdasdfasdfasdf' doesn't exist

Try:

ALTER TABLE `order` AUTO_INCREMENT=1000;

Order is a reserved word, it's trying to order...

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