错误消息
#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 '() NOT NULL,
`content` varchar(255) NOT NULL,
`sent_by` varchar(30) NOT NULL' at line 4
SQL
CREATE TABLE IF NOT EXISTS `chat` (
`id` INT( 10 ) NOT NULL ,
`member_id` VARCHAR( 30 ) NOT NULL ,
`time_sent` DATETIME( ) NOT NULL ,
`content` VARCHAR( 255 ) NOT NULL ,
`sent_by` VARCHAR( 30 ) NOT NULL ,
`seen` INT( 1 ) NOT NULL
) ENGINE = INNODB AUTO_INCREMENT =22 DEFAULT CHARSET = latin1;
现在的问题是什么? 我只是导入我的服务器并发生了这个.. 在我的localhost中导入sql时没问题
答案 0 :(得分:1)
语法问题
- mysql不知道如何解析
root@OpenWrt:~# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 2048 2048 0 100% /rom tmpfs 14052 1128 12924 8% /tmp /dev/mtdblock3 4736 936 3800 20% /overlay overlayfs:/overlay 4736 936 3800 20% / tmpfs 512 0 512 0% /dev root@OpenWrt:~#
的data_type。它只能将datetime或datetime(0-6)理解为有效的data_type s
<强>修复强>
更改
datetime( )
到
`time_sent` DATETIME( ) NOT NULL ,
<强> create table syntax 强>
`time_sent` DATETIME NOT NULL ,
fsp代表小数秒部分,必须在0-6之间
从data_type语法定义,mysql理解
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
(create_definition,...)
[table_options]
[partition_options]
create_definition:
col_name column_definition
...
column_definition:
data_type [NOT NULL | NULL] [DEFAULT default_value]
...
data_type:
...
| DATETIME[(fsp)]
...
或
DATETIME(fsp)
但不是
DATETIME