1. insert插入数据
mysql> insert into score(xid,cid,score,quekao) values ##在score表中插入括号中的四列
mysql> select * from score ##查询score表
2. update
mysql> select * from student;
mysql> update student set xname='xiaowang' where xid=6;
mysql> update student set xname='xiaozhang' where xid=5;
delete
#插入数据:
mysql> insert into student values(21,'xiaoli',22,'f','123','456','上海市','2020-01-01')
#删除插入的数据
mysql> delete from student where xid=行数;
##
伪删除
(1)添加状态列is_del(1代表删除,0代表有效)
alter table student add is_del tinyint not null default 0 comment '1代表删除,0代表有效';
select * from student;
(2)delete ---> update
原语句
delete from student where xid=20;
改为
update student set is_del=1 where xid=20;
(3)更改业务查询方法
原语句
select * from student;
改为
select * from student where is_del=0;
举例:如何删除表中的范围性数据
如删除表中1-5行的数据
delete from t1 where name like '王二%';
delete from t1 where id>1 and id<5;
delete from t1 where id between 1 and 5;
网友评论