错误:
> 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 ''stuent'( 'id' INT(4) NOT NULL auto_increment COMMENT '学号', 'name' VARCH' at line 1 > 时间: 0s
出错误代码:
create table if not exists 'stuent'( 'd' INT(4) NOT NULL auto_increment COMMENT '学号', 'name' VARCHAR(20) NOT NULL DEFAULT'匿名' COMMENT '姓名', 'pwd' VARCHAR(20) NOT NULL DEFAULT '123' COMMIT '密码', 'sex' VARCHAR(2) NOT NULL DEFAULT '女' COMMIT '性别', 'birthday' datetime DEFAULT NULL COMMIT'出生日期', 'address' VARCHAR(100) DEFAULT NULL COMMIT'家庭住址', 'email' VARCHAR(50) DEFAULT NULL COMMIT'邮箱', PRIMARY KEY ('id') )ENGINE=INNODB DEFAULT CHARSET=utf8
修改错误代码:
create table if not exists `stuent`( `id` INT(4) NOT NULL auto_increment COMMENT '学号', `name` VARCHAR(20) NOT NULL DEFAULT'匿名' COMMENT '姓名', `pwd` VARCHAR(20) NOT NULL DEFAULT '123' COMMENT '密码', `sex` VARCHAR(2) NOT NULL DEFAULT '女' COMMENT '性别', `birthday` DATETIME DEFAULT NULL COMMENT'出生日期', `address` VARCHAR(100) DEFAULT NULL COMMENT'家庭住址', `email` VARCHAR(50) DEFAULT NULL COMMENT'邮箱', PRIMARY KEY (`id`) )ENGINE=INNODB DEFAULT CHARSET=utf8;
运行结果正确
总结出错原因:
1:符号错误:
表明和字段名所用的引号应该是(``)而不是(‘’)
2:拼写错误:
comment备注错误,应该是comment而不是commit