(1)insert:插入数据
顺序插入数据
insert into 表名 values(值1,值2,值3); 指定字段插入数据 insert into 表名(字段1,字段2,字段3) values(值1,值2,值3); 插入多条记录 insert into 表名 values(值1,值2,值3),(值1,值2,值3); 插入查询结果 insert into 表1 select (字段1,字段n) from 表2 where 条件;mysql> insert into student values(1,'jack','m',20); \\顺序插入数据mysql> insert into student(name,age) values('bob',21); \\指定字段插入数据mysql> insert into student values(6,'jex','m',21),(7,'bob1','f',22); \\插入多条记录mysql> insert into student_his select * from student where name = 'robby'; \\插入查询结果
(2)update:更新数据
update 表名 set 字段1=新值1,字段2=新值2 where 条件;
mysql> update mysql.user set authentication_string=password('redhat') where user='root' and host='localhost'; \\password()是一个函数mysql> flush privileges;
(3)delete:删除数据
delete from 表名 where 条件;
delete from 表名; //删除表的全部数据