資料庫 限制資料和對資料排序

2021-07-26 23:58:18 字數 1107 閱讀 1664

1、 比較操作符(>、=、<=、<>)

2、 限定資料選擇行

查詢條件為字串時,需加單引號

查詢條件為日期時,格式為』01-1月-15』

例子:select * from emp..

where deptno=10(查詢deptno=10的資料)

3、 特殊比較運算子:

1)between..and..(判斷在某個範圍)

例子:select * from emp where sal between 1500

and2000

2)in(是否和集合中的值相等)

例子:select * from emp where sal in (1500, 2000)
3)like(是否滿足部分匹配)

其中%代表更多字元、_代表乙個字元

例子:select * from emp where ename like

's%'(姓名以s開頭的員工資訊)

select * from emp where ename like

'%t_'(姓名倒數第二個字母為t的員工資訊)

4)is null (是否為空)

例子:select * from emp where ename is

null(ename是否為空的查詢)

4、 邏輯運算子:1)and(或)

2)or(與)

3)not(非)

5、邏輯運算子的優先順序

6、資料排序:使用order by語句(預設為公升序,降序須在結尾加desc)

例子:select * from emp order

by sal(按sal公升序)

select * from emp order

by sal desc(按sal降序)

Oracle 限制資料和對資料的排序

限制條件通過where子句來實現 where子句的寫法 where 列名 比較操作符 比較的值 sal 3000 1.字元型別比較 select ename,sal,deptno from emp where ename tom 注意 1.字元比較用單引號 2.和表中的值一樣,區分大小寫 2.數值比...

Oracle 資料庫 限制資料和資料排序 第三章

使用where子句 比較數值型資料 1.查詢部門編號為10的員工 select from emp where deptno 10 2.查詢部門編號不為10的員工 select from emp where deptno 10 select from emp where deptno 10 比較字元型...

對資料庫的操作

資料庫的檔案 資料檔案 包含資料和物件,主資料檔案建議副檔名.mdf,其餘.ndf 事務日誌檔案 包含恢復資料庫中的所有事物所需的資訊,建議副檔名.ldf 至少包含乙個資料檔案和乙個日誌檔案 對資料庫的操作 選其中乙個,可以選 選其中乙個,必選 分割,表示多個選項 表示說明 建立create dat...