zoukankan      html  css  js  c++  java
  • MySQL 增删改查语句/SELECT INSET INTO UPDATE

    -- 全列插入
            -- insert [into] 表名 values(...)
             insert into classes values(1,"python14");
    -- 部分插入
            -- insert into 表名(列1,...) values(值1,...)
            insert into students(name,high,gender) values("吴彦祖",188.88,1);
    -- 多行插入
    insert into students values(),();
    -- 修改
        -- update 表名 set 列1=值1,列2=值2... where 条件;
            -- 全部修改
            update students set high=170.00;
     
    -- 按条件修改
    update students set high=188.88 where id=2;
     
    -- 查询基本使用
            -- 查询所有列
            -- select * from 表名;
            select * from students;
            -- 定条件查询
            select * from students where id=2;
            -- 查询指定列
            -- select 列1,列2,... from 表名;
            select name,gender from students;
            -- 可以使用as为列或表指定别名
            -- select 字段[as 别名] , 字段[as 别名] from 数据表;
            select name as "姓名",gender as "性别" from students;
     
    -- 删除
            -- 物理删除
            -- delete from 表名 where 条件
            delete from students where id=4;
     
            -- 逻辑删除
            -- 用一个字段来表示 这条信息是否已经不能再使用了
            -- 给students表添加一个 is_delete 字段 bit 类型
            alter table students add is_delete bit default 0;
    update students set is_delete=1 where id=3;
     
  • 相关阅读:
    正则表达式
    理解CPU steal time
    装饰器(带参数)
    装饰器(入门)
    递归
    冒泡算法
    Chrome for Mac键盘快捷键!来自Google Chrome官网!
    swoole深入学习 4. process
    通俗讲解 异步,非阻塞和 IO 复用
    swoole深入学习 3. upd Server和udp Client
  • 原文地址:https://www.cnblogs.com/lab-zj/p/12166521.html
Copyright © 2011-2022 走看看