为什么跟随SQL表创建不起作用?

时间:2015-05-07 14:39:40

标签: mysql django phpmyadmin

CREATE TABLE  `auth_user` (

 `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
 `password` VARCHAR( 128 ) COLLATE utf8_bin NOT NULL ,
 `last_login` DATETIME( 6 ) DEFAULT NULL ,
 `is_superuser` TINYINT( 1 ) NOT NULL ,
 `username` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
 `first_name` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
 `last_name` VARCHAR( 30 ) COLLATE utf8_bin NOT NULL ,
 `email` VARCHAR( 254 ) COLLATE utf8_bin NOT NULL ,
 `is_staff` TINYINT( 1 ) NOT NULL ,
 `is_active` TINYINT( 1 ) NOT NULL ,
 `date_joined` DATETIME( 6 ) NOT NULL ,
PRIMARY KEY (  `id` ) ,
UNIQUE KEY  `username` (  `username` )
) ENGINE = INNODB AUTO_INCREMENT =2 DEFAULT CHARSET = utf8 COLLATE = utf8_bin;

 *\#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 '(6) DEFAULT NULL,
`is_superuser` tinyint(1) NOT NULL,
`username` varchar(30)' at line 4*** 

这是django项目中的auth_user表。 SQL文件是从我的本地MySQL数据库导出的,但我无法导入到在线mysql数据库。有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

您不需要datetime

的长度
`date_joined` DATETIME( 6 ) NOT NULL ,

应该是

`date_joined` DATETIME  NOT NULL ,

https://dev.mysql.com/doc/refman/5.0/en/datetime.html