Oracle 常用SQL總結之一

2021-04-19 02:44:54 字數 745 閱讀 9114

1、distinct :去重複 ,可以跟上一列或多列來排除行重複 

2、<> :不等於 --->select * from emp where empno <>10 ;

3、between  ... and ... 相當與 (>= ... <=)

4、某個欄位的值為空 不是 =null ,而是 is null (is not null 不為空) 

5、in :在某個選值範圍內,使用於有選值範圍----> select * from emo where dep in (1,2); 

6、模糊查詢:要用萬用字元

情況一、值帶%怎麼模糊查詢 :用轉義字元[  /  ]--->select * from emp where ename like '%/%%';

或者可以自己定義轉義字元 select * from emp where ename like '%$%%' escape '$' ;

7、order by :排序,desc 降序

8、lower(引數),upper(引數) 

ename 中第2個字母是a (不管大小寫)的員工的資訊 :select * from emp where lower(ename)  like '_a%';(還有其他方法)

9、to_char(引數,從第幾個開始,擷取幾個) :擷取字串

10、round() :四捨五入,有方法過載

11、to_date() :日期 預設情況下的日期是  例如:26-9月 87

常用的日期函式的截圖 :

oracle總結 常用sql語句

2 顯示當前連線使用者 sql show user 3 檢視系統擁有哪些使用者 sql select from all users 4 新建使用者並授權 sql create user a identified by a 預設建在system表空間下 sql grant connect,resour...

oracle常用sql及函式總結

一.dao層入庫到資料庫系統和當前時間不一致的問題 to char sysdate,yyyy mm dd hh24 mi ss 總結 yyyy 表示 年份,mm 表示 月份,dd 表示 天,hh24 表示 小時,mi 表示 分鐘 ss 表示 秒,to char sysdate,yyyy mm dd ...

Oracle常用的SQL方法總結

在專案中一般需要對一些資料進行處理,以下提供一些基本的sql語句 1.基於條件的插入和修改 需要在表中插入一條記錄,插入前根據key標識判斷。如果識別符號不存在,則插入新紀錄,如果識別符號存在,則根據語句中所給的新值對原紀錄中的字段進行更新 merge into ausing b on a.key ...