简体   繁体   中英

MYSQL Table Error - 1064

Trying to create the following table:

CREATE TABLE login (
        IdUser int(11) NOT NULL AUTO_INCREMENT,
        username varchar(45) CHARACTER SET latin1 NOT NULL,
        pass varchar(45) CHARACTER SET latin1 NOT NULL,
        PRIMARY KEY (IdUser),
        ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$);

Doesn't seem to work properly. The error I'm getting in MYSQL is:

#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 '=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$' at line 6

Bracket in the wrong spot:

PRIMARY KEY (IdUser),
ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$);
                                                     ^----

should be

PRIMARY KEY (IdUser)   <--note removed comma
) ENGINE=MyIsam etc...
^---

You're treating those table options as they were fields, by placing them WITHIN the () field definition block.

In my case some of the sql is working but mostly not working after changing Type=ENGINE.

CREATE TABLE `p4_acl_page` (
  `id` int(2) NOT NULL auto_increment,
  `label` varchar(80) default NULL,
  `lastupdate` timestamp(14) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyIsam;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM