创建一个表,表中列weight
带有括号
create table student(
id int auto_increment,
name varchar(20),
weight(kg) int,
primary key (id)
)engine=innodb;
会出现报错
对于带括号的列需要用反引号`
将其标记起来
create table student(
id int auto_increment,
name varchar(20),
`weight(kg)` int,
primary key (id)
)engine=innodb;
对于表中带括号的列的修改以及表的查询也是同样的做法
alter table students add `weight(kg)` int;
select `weight(kg)` from students;