zoukankan      html  css  js  c++  java
  • mysql基本操作之表的增删改(二)

    首先我们创建一张用户表

     -- 创建表
        create table user(
            id int primary key  auto_increment,
            name varchar(10),
            age tinyint
        )charset utf8 comment '用户表';

    然后往表里插入数据

    -- 插入数据
        insert  into  user(id,name,age)value(2,'chris',21);
        -- 或可以这么写
        insert into user value (1,'jamal',18);
        -- 也可以批量插入
        insert into user values(3,'durant',30),
                                 (4,'wall',21);

    删除表中的某一行数据

    -- 删除表中的id为1数据
        delete from user where id = 1;
        -- 删除表中name为durant的数据
        delete from user where name = 'durant';
        -- 删除表中age为21的数据
        delete  from user where age = 21;

    更新表中的某一行数据

     -- 更新表中id为2,名字改为yongjar
        update user set name = 'yongjar' where  id = 2;
        -- 更新表中名字为wall,年龄改为31
        update user set age = 21 where  name = 'wall';
  • 相关阅读:
    UESTC
    Education Round 8 A
    Gym
    Gym
    hdoj 1159 Common Subsequence
    UVA
    UESTC
    51Nod 1068 Bash游戏 V3 (这规律不好找)
    51Nod 1066 Bash游戏
    51Nod 1002 数塔取数问题
  • 原文地址:https://www.cnblogs.com/jamal/p/10958037.html
Copyright © 2011-2022 走看看