2016-10-03 65 views
1

這是我的表格導出:ALTER TABLE table_name AUTO_INCREMENT = 1000;給我的語法錯誤

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 ; 

,當我現在運行:

ALTER TABLE order AUTO_INCREMENT=1000; 

我得到:

#1064 - 你在你的SQL有一個錯誤句法;檢查手冊中 對應於你的MySQL服務器版本正確的語法使用 附近「爲了AUTO_INCREMENT = 1000」第1行

表是空的!

MySQL版本:5.5.44-0ubuntu0.14.04.1

有人有一個想法是什麼可能導致我這個問題?

,如果我把比如這個:

ALTER TABLE asdasdfasdfasdf AUTO_INCREMENT=1000; 

我得到

1146 - 表 'mydb.asdasdfasdfasdf' 不存在

+1

可能是因爲順序是特殊字? – Batanichek

回答

5

嘗試:

ALTER TABLE `order` AUTO_INCREMENT=1000; 

Ord呃是一個保留字,它試圖訂購...

+1

什麼是#$&!笑話 – Toskan

+0

@Toskan我想你應該說'#$&!ing' –