增
insert into 表名(列1,列2...列N) values(值1,值2...值N);
commit
rollback commit後不能再rollback
刪
delete 會發起事務,可以有where過濾條件
truncate 不會發起事務,不能有where過濾條件,有外鍵情況不能使用,效率高
查
distinct 去重
!= 等價於 <>
between 算頭算尾
% 匹配空白或多個字符
_ 匹配任意單一字符
asc 升序(默認,與order by聯用)
desc 降序
舉個栗子
1、查找出獎金超過本人基本工資3%的職工的姓名,工資,獎金,獎金與工資的比例,並按其比例由高到低顯示
select e.ename,e.sal,e.comm,(e.comm/e.sal)
from emp e
where (e.comm/e.sal)>0.03 order by e.comm/e.sal desc;
2、按工種升序,而同工種按工資降序排列顯示全部職工的姓名,工種,工資。
select e.ename,e.job,e.sal
from emp e
order by e.job asc,e.sal desc;
select * from emp e2
where e2.job not in('MANAGER','CLERK') and e2.deptno = 20;
程序的執行順序:from子句→where子句→select子句。
PS:oracle沒有limit,用rownum來篩選前幾的排序