1. 程式人生 > >Oracle 常用SQL總結之一

Oracle 常用SQL總結之一

  1. 1、distinct :去重複 ,可以跟上一列或多列來排除行重複 
  2. 2、<> :不等於 --->select * from emp where empno <>10 ;
  3. 3、between  ... and ... 相當與 (>= ... <=)
  4. 4、某個欄位的值為空 不是 =
    null ,而是 is null (is not null 不為空) 
  5. 5、in :在某個選值範圍內,使用於有選值範圍----> select * from emo where dep in (1,2); 
  6. 6、模糊查詢:要用萬用字元
  7.    情況一、值帶%怎麼模糊查詢 :用轉義字元[  /  ]--->select * from emp where ename like 
    '%/%%';
  8.    或者可以自己定義轉義字元 select * from emp where ename like '%$%%' escape '$' ;
  9. 7、order by :排序,desc 降序
  10. 8、lower(引數),upper(引數) 
  11.  ename 中第2個字母是a (不管大小寫)的員工的資訊 :select * from emp where lower(ename)  like 
    '_a%';(還有其他方法)
  12. 9、to_char(引數,從第幾個開始,擷取幾個) :擷取字串
  13. 10、round() :四捨五入,有方法過載
  14. 11、to_date() :日期 預設情況下的日期是  例如:26-9月 87 
  15. 常用的日期函式的截圖 :