简体   繁体   中英

Syntax error creating MySQL table

Perhaps I'm just too used to Postgres but why am I getting this error

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 '{ id int not null AUTO_INCREMENT, email varchar(100) not null, primary key(id' at line 1

when I run this?

create table `users`{
    id int not null AUTO_INCREMENT,
    email varchar(100) not null,
    primary key(id)
};

Use parenthesis (normal brackets) () not braces:

create table `users` (
    id int not null AUTO_INCREMENT,
    email varchar(100) not null,
    primary key(id)
);

the correct syntax is :

CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT,
email VARCHAR(100) NOT NULL,
PRIMARY KEY(id) );

check it out here for your version:

https://dev.mysql.com/doc/refman/4.1/en/creating-tables.html

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