MySQL必知必会 - 增删改数据表记录操作

插入

插入完整的行
insert into student values(1,"小明",8,"男",3,null);
插入行的一部分
insert into student (id,name,age,sex) values(2,'小王',9,'女');
插入查询结果
insert into student (cloumn_name1,cloumn_name2,...)
select cloumn_name1,cloumn_name2,... from another_table;

复制表

create table student_copy as select * from student;

删除

删除所有行(不删除表)
delete from student;
删除特定的行
delete from student where sex='女';

更新

更新一行中的某一列
update student set grade=4 where name='小王';
更新一行中的多列
update student set grade=4,class=1 where name='小王';
更新所有行
update student set grade=4