我正在尝试创建表,然后显示以下错误。但我找不到错误。我是Mysql的新手请帮助我..
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
答案 0 :(得分:3)
问题:
title
VARCHAR(50)字符:VARCHAR(50)就足够了,MySQL不支持这种语法。description
文字字符:使用一个TEXT或CHAR 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;