MySQL数据操作:增删改查

MySQL数据库的增删改查

增--插入数据insert

insert into 表(字段,...) values (值,...);
 insert into t1 value (1,'大壮','male','上课,写作业');
 insert into t1 values(2,'杜相玺','male','写作业,考试');
 insert into t1 values(3,'b哥','male','写作业'),(4,'庄博','male','考试');
 insert into t1(username,hobby) values ('杨得港','上课,写作业,考试'),('李帅','考试')
 insert into t2(id,name) select id,username from t1;

删--删除数据delete

 清空表
     delete from 表;
         会清空表,但不会清空自增字段的offset(偏移量)值
     truncate table 表;
         会清空表和自增字段的偏移量
 删除某一条数据
     delete fromwhere 条件;

改--更新数据update

     updateset 字段=where 条件;
     updateset 字段=值,字段=where 条件;

查--查询数据 search

  1,单表查询

  2,连表查询

猜你喜欢

转载自www.cnblogs.com/CatdeXin/p/11069572.html
今日推荐