cissdy 发表于 2011-12-23 03:17

oracle 表的基本查询

<DIV><FONT color=#800080 size=4>表的基本查询</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp; 1,查看表结构</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; Desc dept;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;2,查看所有列 </FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; select * from dept;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;3, 查看指定列</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; select ename,sal,job,deptno from emp;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;4,如何取消重复</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; select distinct deptno,job from emp;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;5,set timing on; 显示查询时间</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;6,使用算术表达式</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; ? 显示每个雇员的年工资</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; select(sal+nvl(comm,0))*12 as 年工资,ename as 姓名 from emp;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;使用列的别名</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp; select ename "姓名",sal*12 as "年收入" from emp;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;? 如何使用null值</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp; 使用nvl函数来处理</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;如何连接字符串(||)</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp; select ename || 'is a '|| job from emp;</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;7, 使用where 子句</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; ?如何显示工资高于3000的员工</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp; <a href="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201109/17/25472509_1316258791kp8B.jpg" target="_blank"><IMG src="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201109/17/25472509_1316258791kp8B.jpg" .load="imgResize(this, 650);" border=0 ;></A></FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp;&nbsp; 。。。。。</FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT color=#800080 size=4>&nbsp;&nbsp; </FONT></DIV>
<DIV>&nbsp; </DIV>
<DIV><FONT color=#800080 size=4>&nbsp; </FONT></DIV>
页: [1]
查看完整版本: oracle 表的基本查询