select之二

1.字段表达式
         运算符号
数字类型
         日期类型
               + - *  /
null+任何值=null
字符类型
||
  2.Oracle支持的数据类型
        内部类型
   数字类型 number
   日期类型 date
            字符类型 varchar2
用户类型
   integer |
   float   |  number
   double  |
    3.特殊的数据
        NULL值与0
使用nvl判定字段的是否为空,为空的时候改为0
select nvl(commision_pct,0)from sem;
    4.注意
      SQL语句使用 ;结束
      --注释
      remark 注释
      输出 prompt
    5.SQL的结构化查询特点
        Struct Query Language
      结构:
 分段
      select段
      from段
      是必须
      from 表1,表2
    6.where从句 查询的辅助结构 
       where必须紧跟from段
       select * from sem where id=1
       where中字符串中字符大小写区分
     6.1
       = > >= < <= != <> chang /!=/<> ^=不等
       select * from sem 
       where id<10
       改变语句c/</<=10
       参与运算的数据类型是所有类型
       建议最好用在数据类型,日期类型
       返回bool值
     6.2
betwwen and
包含边界值
select id,salary from sem 
where salary between 1000 and 20000;
     6.3
in(int 1,int 2)判断字段是否在列表中
select id,salary from emp where salary in(1200,1300..);
     6.4
like 值
select id from emp where id like 2;
select first_name ,id from emp where first_name like 'a';
select first_name  from emp where first_name like '_a%';
_代表一个字符 %任意多个或0个统配符
     6.5 
is null
判定值是NULL字段
select id from emp where commission_pct is null;
     66
可以在表达式中使用()改变运算的优先级别
     6.7 多条件
not 不可以放在比较>...符号之前,in like betwwen ..可以
and
or
可以使用()改变运算的先后顺序
select id from sem where not id in(11,22,33,55);
select id from sem where id not in.....
select id from sem where not id >50;
select id from sem where id is not null;
select id from sem where salary<=500 and nvl(commission_pct,0)=0;
     6.8 like中的歧义字符转义
escape '字符' 指定转义符号
select table_name from user_name where 
table_name like 's\_%'escape'\'; 防止字段中存在%,那样就不能使用统配符的,\后面的字符 是原义
   7. order by排序
     7.1 order by 只能where后面
order by是最后一个从句
 select salary ,id from sem order by salary;
 select id from sem order by salary;    
     7.2 order by后可以是字段以及字段表达式
 select id,commission_pct from sem order by commission_pct;
 注意NULL值按照最大排序
     7.3  多字段排序
 select salary,id from dept order by salary,id;
 排序优先是从前到后
     7.4  排序的方式
          升序/降序
 select salary,id from dept order by salary,id asc;
 select salary,id from dept order by salary,id desc;
 字段 排序方式,字段 排序方式
          select salary,id from dept order by salary asc,id desc;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值