mysql 插入语句

什么时候用单引号,什么时候不用?

1、先创建一个表

create table user(
username varchar(255),
age int,
marry boolean,
birthday date
);

【注意,最后一个括号前面不能有逗号,否则出错】

2、插入语句

insert into user values('bluewelkin',20,1,1985-10-10); 失败。。因为最后一个日期没有加引号

insert into user(username,age,marry) values('李四',20,1); 成功

 insert into user(username,age,marry) values('bluewelkin',20,1);  成功

 insert into user values('bluewelkin','20','1','1985-10-10'); 成功→和上面比较,int数字类型,数字可以加引号,也可以不加

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-08-12
  • 2021-12-22
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
相关资源
相似解决方案