mysql数据级别操作

mysql的数据操作(增删改查)

增加数据

  • insert into 表名(字段名1,字段名2,……) value(值1,值2,…..);
    • insert into t1(id,name) value(1,'小新');
  • insert into 表名(字段名1,字段名2,……) value(值1,值2,…..),(值1,值2,…..),……..;
    • insert into t1(id,name) value(1,'小新'),(2,'小白'),(3,'小黑');
  • insert into 表名(字段名1,字段名2,……) select (字段名1,字段名2,……) from 外表名
    • 从外表中查询到数据写入表中
    • insert into t1(id,name) select (id,username) from t2;

删除数据

  • delete from 表名 where 筛选条件;
    • delete from t1 where id>9 and age=18;
  • delete from 表名;
    • 会清空表中数据,但不会删除表中自增字段的offset(偏移量)
    • delete from t1;
  • truncate table 表名;
    • 会清空表中数据,同时会删除表中自增字段的offset(偏移量)
    • truncate table t1;

修改数据

  • update 表名 set 字段名1=值1,字段2=值2,…… where 筛选条件
    • update t1 set age=20,birthday=19700101 where id=1;

查询数据

单表查询

mysql单表查询
https://www.cnblogs.com/Programmatic-yuan/articles/13037739.html

多表查询

mysql多表查询
https://www.cnblogs.com/Programmatic-yuan/articles/13037555.html

posted @ 2020-05-31 13:30  yyyzh  阅读(170)  评论(0编辑  收藏  举报