zoukankan      html  css  js  c++  java
  • mysql 单表下的字段操作

    如下只介绍单表的添加、更新、删除、查询表结构操作,查询数据操作范围太大用单独的篇幅来讲解;

    查看表结构

    desc test_tb;
    

    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
    

    更新指定条件的数据

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

    Delete 删除数据

    删除全部数据

    Delete from test_tb;
    

    删除指定条件的数据

    Delete from test_tb where id = 1;

  • 相关阅读:
    UI自动化实现多浏览器运行
    【转】C#操作XML方法集合
    日拱一卒
    敏捷开发- planning会议中的开会趣事
    敏捷开发- 可行走的骨骼
    敏捷开发- 测试人员何去何从
    Nunit & Specflow
    [转]根本原因分析(Root Cause Analysis)
    Selenium 中抓取dropdown
    网页模板
  • 原文地址:https://www.cnblogs.com/mysticbinary/p/12865739.html
Copyright © 2011-2022 走看看