• sql 基础--mysql 5 (10)


    17.更新和删除数据

    更新: update table set columns =  ‘value’ where ...

    mysql> update pw_price set price=10000 where uid=6;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from pw_price;
    +-----+-------+------------+
    | uid | price | first_name |
    +-----+-------+------------+
    |   1 |   100 | wang       |
    |   2 |  1000 | zhang      |
    |   3 |  2000 | li         |
    |   4 |  5000 | weizhi     |
    |   5 |  5000 | cai        |
    |   6 | 10000 | guo        |
    +-----+-------+------------+
    6 rows in set (0.00 sec)
    mysql> update pw_price set first_name="guo6" where uid = 6;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from pw_price;
    +-----+-------+------------+
    | uid | price | first_name |
    +-----+-------+------------+
    |   1 |   100 | wang       |
    |   2 |  1000 | zhang      |
    |   3 |  2000 | li         |
    |   4 |  5000 | weizhi     |
    |   5 |  5000 | cai        |
    |   6 | 10000 | guo6       |
    +-----+-------+------------+
    6 rows in set (0.00 sec)

    删除数据

    delete from table where 。。。

    mysql> select * from pw_price;
    +-----+-------+------------+
    | uid | price | first_name |
    +-----+-------+------------+
    |   1 |   100 | wang       |
    |   2 |  1000 | zhang      |
    |   3 |  2000 | li         |
    |   4 |  5000 | weizhi     |
    |   5 |  5000 | cai        |
    |   6 | 10000 | guo6       |
    +-----+-------+------------+
    6 rows in set (0.00 sec)
    
    mysql> delete from pw_price where uid >=6;
    Query OK, 1 row affected (0.03 sec)
    
    mysql> select * from pw_price;
    +-----+-------+------------+
    | uid | price | first_name |
    +-----+-------+------------+
    |   1 |   100 | wang       |
    |   2 |  1000 | zhang      |
    |   3 |  2000 | li         |
    |   4 |  5000 | weizhi     |
    |   5 |  5000 | cai        |
    +-----+-------+------------+
    5 rows in set (0.00 sec)
  • 相关阅读:
    mybaits源码分析--事务管理(八)
    mybaits源码分析--binding模块(五)
    mybaits源码分析--自定义插件(七)
    mybaits源码分析--缓存模块(六)
    2021年9月
    golang-reflect实战ini配置文件
    ECC加密原理详解
    RFID 随手记
    计算机实现加法
    公钥加密算法 RSA
  • 原文地址:https://www.cnblogs.com/wjw334/p/4305400.html
Copyright © 2020-2023  润新知