前端之家收集整理的这篇文章主要介绍了
万事俱备之ORACLE_SQL 练手 part2,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
脚本和更多参考见:
1.万事俱备之ORACLE_SQL 练手 part1
select ENAME from EMP where ename like '__A%';
select ENAME from EMP where ename like '%A%' and ename like '%N%';
SELECT ENAME,COMM FROM EMP;
SELECT * FROM DEPT ;
SELECT ENAME,SAL+COMM ACTSAL,COMM FROM EMP WHERE COMM!=0 ORDER BY ACTSAL DESC;
SELECT DISTINCT JOB FROM EMP WHERE DEPTNO=20;
select distinct dname,loc from dept where dname!='SALES';
SELECT * FROM (SELECT ENAME,SAL+NVL(COMM,0) ACSAL FROM EMP) WHERE ACSAL NOT BETWEEN 1000 AND 1500 ORDER BY ACSAL ;
select *from (select ename,job,(sal+nvl(comm,0))*12 ansal from emp where job ='MANAGER' or job ='SALESMAN') --where ansal between 21000 and 15000;
where ansal between 15000 and 21000;
SELECT EMPNO,COMM FROM EMP WHERE COMM = NULL ;
SELECT EMPNO,COMM FROM EMP WHERE COMM IS NULL;
列出当前用户有多少张数据表,结果集中存在多少条记录。
SELECT 'SELECT * FROM '||TABLE_NAME||';' FROM USER_TABLES;
'1500'为字符,一开始以为会,就直接忽视它了2223
结果是:不会,oracle 会将字符型转换成数值型,但这样会降低查询的效率,因为oracle会花费时间去进行隐性的数据类型转换
原文链接:https://www.f2er.com/oracle/206475.html