问题
Error:
#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 '‘00000000000’ membership_status ENUM(‘gold’,‘silver’,‘bronze’,' at line 5
SQL:
CREATE TABLE members(
member_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60)NOT NULL,
birthday DATE NOT NULL,
phone CHAR(10)NOT NULL DEFAULT ‘00000000000’,
membership_status ENUM(‘gold’,‘silver’,‘bronze’,‘nam’)NOT NULL DEFAULT ‘nam’,
PRIMARY KEY(member_id)
)
回答1:
I'd guess it was the funky single quotes you're trying to use. Try this with standard '
single quotes
CREATE TABLE members(
member_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60)NOT NULL,
birthday DATE NOT NULL,
phone CHAR(10)NOT NULL DEFAULT '00000000000',
membership_status ENUM('gold','silver','bronze','nam') NOT NULL DEFAULT 'nam',
PRIMARY KEY(member_id)
)
回答2:
try this
CREATE TABLE members(
member_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60)NOT NULL,
birthday DATE NOT NULL,
phone CHAR(10)NOT NULL DEFAULT '0000000000',
membership_status ENUM('gold','silver','bronze','nam')NOT NULL DEFAULT 'nam',
PRIMARY KEY(member_id)
)
I changed the single quotes to plain ' and your default value for phone was also 1 to many 0s
回答3:
The single quotes used are not recognized by the database server. Replace those fancy quotes with the regular one ' and you will be okay.
Note that you'll encounter problems in other programs as long as you use that kind of quotes as they are not the proper quotes to be used.
Hope this helps.
来源:https://stackoverflow.com/questions/17728542/weird-mysql-syntax-error-with-simple-create-table-statement