Mysql_单表字段操作_插入 更新 删除


如下只介绍单表的添加、更新、删除操作,查询用单独的篇幅来讲解;

Insert 插入数据

插入 = 添加

为表中指定的字段插入数据

Create table student(
    id int(4),
    name varchar(20) not null,
    grade float
);
Insert into test_tb(id,name,grade) values(1,"lisi",98);

不指定字段插入数据

不指定字段,就相当于每个字段都要填充值才行;

Create table student(
    id int(4),
    name varchar(20) not null,
    grade float
);
Insert into test_tb values(1,"lisi",98);
# 由于没有指定字段,那么顺序和数量一定得和表中的字段顺序、数量都得一致;

同时插入多条记录

批量插入

Create table student(
    id int(4),
    name varchar(20) not null,
    grade float
);
Insert into test_tb(id,name,grade) values(1,"lisi",98),(2,"wangwu",60),(1,"chenliu",76);

Update 更新数据

更新Set 字段下全部数据

Update test_tb Set age=18,sex=1

1552062-20190811144652804-150136247.png

更新指定条件的数据

Update test_tb Set age=18,sex=1 where id=1;

Delete 删除数据

删除全部数据

Delete from test_tb;

删除指定条件的数据

Delete from test_tb where id = 1;

转载于:https://www.cnblogs.com/mysticbinary/articles/11329389.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值