标签:case sel oracle delete rod sysdate 姓名 索引排序 ase
Oracle关键字的使用
使用insert 添加数据: INSERT INTO 表名 VALUES (加入对应的数); COMMIT;
INSERT INTO p_emp
VALUES(‘TOM2‘, ‘CLERK‘, 7902, SYSDATE, 1000, NULL, 30);
COMMIT;
试用DELETE删除一条数据: DELETE 表名 WHERE 条件; COMMIT;
DELETE p_emp e WHERE e.empno=1;
COMMIT;
使用UPDATE修改数据: UPDATE 表名 SET 修改内容 WHERE 条件; COMMIT;
UPDATE p_emp e SET e.ename=‘TOM3‘ WHERE e.empno=2;
COMMIT;
IN 关键字 ,查询在符合IN条件的数据。例:查询工资为800,3000,5000的员工信息
SELECT * FROM p_emp e WHERE e.sal IN (800, 3000, 5000);
LIKE关键字,模糊查询,%表示任意个字符, _表示单个字符。例:查询以T开头的所以员工的信息
SELECT * FROM p_emp e WHERE e.ename LIKE ‘T%‘
ORDER BY,按列名或索引排序
SELECT * FROM p_emp e ORDER BY e.job DESC, e.sal DESC
SELECT * FROM p_emp e ORDER BY 3, 6
GROUP BY 按某几列分组
SELECT e.job FROM p_emp e GROUP BY e.job HAVING COUNT(*) > 2
使用SUM,AVG,MOD,COUNT函数
SELECT p.toma,p.ptype,SUM(p.lastcou) FROM product p GROUP BY ROLLUP (p.toma,p.type)
CASE WHEN THEN / DECODE的使用
CASE * WHEN 条件THEN 显示的内容
DECODE(*,’条件’,’显示的内容’)
SELECT T.ENAME,
CASE T.SEX WHEN 1 THEN ‘男‘ WHEN 0 THEN ‘女‘ ELSE ‘kk‘ END
FROM P_EMP T
SELECT T.ENAME 姓名,
CASE WHEN T.SEX = 1 THEN ‘男‘ WHEN T.SEX = 0 THEN ‘女‘ ELSE ‘kk‘
END 性别
FROM P_EMP T
DISTINCT去除重复
SELECT DISTINCT t.job FROM p_emp t
BETWEEN a AND b 在a和b之间
select * FROM p_emp t WHERE t.sal BETWEEN 2000 AND 3000
标签:case sel oracle delete rod sysdate 姓名 索引排序 ase
原文地址:http://www.cnblogs.com/DONGb/p/7358084.html