04_mysql增删改操作

1 插入数据记录

1.1 插入完整数据记录

insert into student value(1,'zhaodi',25,1,97);
insert into student(stu_no,stu_name,stu_age,stu_sex,stu_score) VALUE(3,"zhaodi",24,1,99);

1.2 插入部分数据记录

insert into student(stu_no,stu_name) VALUE(2,"zhaodi2");

1.3 插入多条记录

insert into student VALUES(4,"zhaodi",34,0,55),(5,'zhaodi',45,4,55);

1.4 插入查询结果

INSERT into student select * from student where stu_no = 1;

注意的是,插入的字段和select 的字段必须完全相同

2 更新数据记录

  • 更新特定的数据记录
update student set stu_name = 'zhaodi', stu_sex = 1 where stu_no = 1;
  • 更新所有的数据记录
update table_name set field = value,.... ,where condition;

3 删除数据记录

  • 删除特定的数据记录
delete from table_name where condition;
  • 删除所有的数据记录
一个小小的程序员
原文地址:https://www.cnblogs.com/zhaod/p/8366212.html