2014-01-23 102 views
0

我正在嘗試創建表,然後顯示以下錯誤。但是我找不到這個錯誤。我是在MySQL的新請幫助我..MySQL#1064 - 您在SQL語法中出錯

SQL查詢:

-- 
-- Dumping data for table `files` 
-- 
-- -------------------------------------------------------- 
-- 
-- Table structure for table `post` 
-- 
CREATE TABLE IF NOT EXISTS `offer` ( 
offer_id INT(9) NOT NULL AUTO_INCREMENT , 
offer_category VARCHAR(50) CHARACTER SET utf8 NOT NULL , 
offer_type VARCHAR(50) CHARACTER SET utf8 NOT NULL , 
sub_category_id INT(9) NOT NULL , 
category_id INT(9) NOT NULL , 
state_id INT(9) NOT NULL , 
city_id INT(9) NOT NULL , 
location_id INT(9) NOT NULL , 
file_id INT(9) NOT NULL , 
title VARCHAR(50) CHARACTER, 
description TEXT CHARACTER, 
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , 
exp_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , 
shop_id INT(9) NOT NULL , 
status TINYINT(1) NOT NULL , 
PRIMARY KEY ( offer_id) 
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =63; 

誤差,

MySQL said: Documentation 

     #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 ' 
      `description` text CHARACTER, 
      `date` timestamp NOT NULL DEFAULT CURRENT_TI' at line 22 
+3

'描述TEXT'沒有'CHARACTER',或指定一個有效charset:'CHARACTER SET utf8' – BlitZ

+1

基本上,發生的事情是你不能導入SQL轉儲。這看起來並不像你自己創造了所有這些,如果你對MySQL太新了,這會讓我斷定你正在做一些有關你一無所知的事情的有償工作,並且你想從SO獲得免費的幫助而不是學習經驗。 –

回答

3

問題:

  1. title VARCHAR(50)字符: VARCHAR(50)就夠了,MySQL不支持這種語法。
  2. description文本字符:使用一個TEXT或CHAR
  3. 兩列不能有CURRENT_TIMESTAMP

試試這個

CREATE TABLE IF NOT EXISTS `offer` (

`offer_id` INT(9) NOT NULL AUTO_INCREMENT , 
`offer_category` VARCHAR(50) CHARACTER SET utf8 NOT NULL , 
`offer_type` VARCHAR(50) CHARACTER SET utf8 NOT NULL , 
`sub_category_id` INT(9) NOT NULL , 
`category_id` INT(9) NOT NULL , 
`state_id` INT(9) NOT NULL , 
`city_id` INT(9) NOT NULL , 
`location_id` INT(9) NOT NULL , 
`file_id` INT(9) NOT NULL , 
`title` VARCHAR(50) , 
`description` TEXT , 
`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , 
`exp_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' , 
`shop_id` INT(9) NOT NULL , 
`status` TINYINT(1) NOT NULL , 
PRIMARY KEY ( `offer_id`) 
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =63; 
相關問題