当前位置:数据库 > Oracle >>

Oracle单表的简单查询

Oracle单表的简单查询
 
查看表结构
desc emp;
查询所有列
Select * from emp;
查找所以部门编号(查指定的列)
select deptnofrom emp;
查找编号不同的部门编号(去重)
selectdistinct deptnofrom emp;
查找ename为SMITH的员工职位,工资,部门编号
select job,sal,deptnofrom emp t  where t.ename='SMITH';
查找员工的年薪
NVL( string1, replace_with)
功能:如果string1为NULL,则NVL函数返回replace_with的值,否则返回string1的值
SELECT sal*12+nvl(comm,0)*12as salsun , ename,sal,comm  from emp

 

 
 
别名的应用
select salas "工资"from emp
查询工资大于1000的员工工资
select salas "工资"from empwhere sal>1000
查找1982.1.1后入职的员工
select ename,hiredatefrom empwhere  hiredate>'1-1月-1982'
显示工资在2000到3000的员工
select ename,salfrom empwhere sal>=2000and sal<=3000;
模糊查询like,%,_
select ename,salfrom emp t   where t.enamelike'%S%';
select ename,salfrom emp t where t.enamelike'_O%';
in的使用
select sal,enamefrom emp twhere t.salin(800,1600)
is null的使用
select *from empwhere mgrisnull;

 


Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,