首页 > 代码库 > DML操纵语句

DML操纵语句

--在新增数据的时候,如果在表名之后没有跟 列名,那么values()必须写全
--顺序必须不能改变,这个顺序就是表中列的顺序
insert into dept
values(70,‘20‘,‘哈哈‘)
insert into dept(deptno,dname)
values(70,‘20‘)
--查询所有教师
select * from teacher
--修改姓马的教师部门编号为10
update teacher set deptno=10 where tname like ‘马%‘
--查询所有姓马的老师信息
select tname,deptno from teacher where tname like ‘马%‘


--查询陈老师和韩老师的薪水
select tname,sal from teacher where tname like ‘陈%‘ or tname like ‘韩%‘
--给所有叫陈老师和韩老师加薪2000
update teacher set sal=sal+2000 where tname like ‘陈%‘ or tname like ‘韩%‘


--查询所有姓赵的老师
select * from teacher where tname like ‘赵%‘
--删除所有姓赵的老师
delete from teacher where tname like ‘赵%‘

--删除所有教师和部门
delete from teacher
delete from dept
--删除教师和部门表
drop table teacher
drop table dept

DML操纵语句