Aldebaranb 2023-03-19 17:02 采纳率: 0%
浏览 84

mysql创建数据表报错

create table 's'(
-> 'sno' char(10) not null comment '学号',
-> 'sn' varchar(45) not null comment '姓名',
-> 'sex' enum('男','女') not null default '男' comment '性别',
-> 'age' int not null comment '年龄',
-> 'maj' varchar(45) not null comment '专业',
-> 'dep' varchar(45) not null comment '院系',
-> primary key ('sno')
-> );
报错是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 ''s'(
-> 'sno' char(10) not null comment '学号',
-> 'sn' varchar(45) ' at line 1
怎么抄书也有问题呢

  • 写回答

5条回答 默认 最新

  • 追cium 2023-03-19 17:11
    关注

    参考GPT和自己的思路:

    这个报错是因为单引号被错误地放置在表名和列名周围,正确的语法应该是使用反引号或不使用引号来引用它们。修改后的代码如下:

    create table s(
    sno char(10) not null comment '学号',
    sn varchar(45) not null comment '姓名',
    sex enum('男','女') not null default '男' comment '性别',
    age int not null comment '年龄',
    maj varchar(45) not null comment '专业',
    dep varchar(45) not null comment '院系',
    primary key (sno)
    );

    希望这个回答对您有帮助!

    评论

报告相同问题?

问题事件

  • 创建了问题 3月19日