MySQL-插入语句

image

image

1.插入的值的类型要与列的类型一致或兼容

# 1.插入的值的类型要与列的类型一致或兼容
insert into beauty(`id`,`name`,`sex`,`borndate`,`phone`,`photo`,`boyfriend_id`)
values(13,'杨一心','女','1990-4-23','7518613969',null,2);

image

这样就插入了

不可以为NULL的列必须插入值,可以为NULL的列如何插入值

image

上面就是解决方法 即:可以写NULL 也可以这一列和值都不写

image

列的顺序是可以调换的

image

image

上面为插入的方式一

接下来讲插入的方式二

image

INSERT INTO beauty
SET id=19,NAME='sss',phone=1234

image

两种插入方式的大比拼

image

方式一支持子查询,方式二不支持

# 方式一支持子查询,方式二不支持
insert into beauty(id,name,phone)
select 26,'hh','3456789';

image

image

posted @ 2022-05-23 13:29  司砚章  阅读(938)  评论(0编辑  收藏  举报