你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle入门命令

[日期:2012-03-13] 来源:Linux社区  作者:hanxiaoshuang [字体:大 中 小]
14.比较运算符  >  < == 
    select * from emp where sal >1000; 
    select * from emp where sal >=3000; 
select * from emp where sal<=3000; 
    select * from emp where sal <>3000; 
    select * from emp where sal !=3000; 
select * from emp where sal between 1600 and 300; 
select * from emp where job in('SALESMAN','MMANAGER'); 
select * from emp where sal in(1600,3000); 
    select * from emp where sal=1600 or sal=3000; 
15.模糊查询 
    select * from emp  where ename like '%SN%';   
    select * from emp  where ename like 'SM%'; 
select * from emp  where ename like '%SM'; 
 
SQL> --在Oracle中  % _是有多个含义的   % 0-多个字符   - 一个字符 
SQL> --字段内容   % _ 没有任何含义  结合\ escape来实现 
    select * from jobs where job_id like 'IT\_%' escape '\' ; 
 
select * from emp where comm is not null; 
select * from emp where sal>1600 and job='MANAGER'; 
select * from emp where sal>1600 or job='MANAGER'; 
select * from emp where job in('MANAGER','SALESMAN') 
select * from emp where job not in('MANAGER','SALESMAN') 
16.排序 
    select * from emp order by sal; 
    select * from emp order by sal desc; 
    select * from emp order by comm; 
select * from emp order by comm desc; 
select * from emp order by nvl(comm,0) desc; 
select * from emp order by hiredate; 
 
SQL> --按别名排序 
SQL> select sal*12+nvl(comm,0) from emp order by sal*12+nvl(comm,0); 
 
select sal*12+nvl(comm,0) as salary from emp order by salary; 
 
    SQL> --多个列排序 
SQL> select * from emp order by deptno,sal; 
     
17.有时候在查出来的格式不好看的话,可以调整一下,有时候col value for 9999改变不了,所以要用以下的sql语句: 
SQL> set linesize 120 
SQL> col value for a20 
SQL> col parameter for a40 
     
 
注意:SQL 语言大小写不敏感。  
SQL 可以写在一行或者多行 
关键字不能被缩写也不能分行 
各子句一般要分行写。 
使用缩进提高语句的可读性。  linux
相关资讯       oracle数据库教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款