標籤:
其他: 電腦中的記憶體是線性,一維。 length(‘‘)計算字元的個數,而不是位元組的個數 Oracle中的日期類型和數實值型別的資料可以做運算子(>,=,<,<>)比較如果在啟動Oracle資料庫的時候出現了:ora-12514的錯誤編號的提示。解決方案: 去Oracle安裝目錄下面找到:C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN目錄下面: 找到:listener.ora檔案和tnsnames.ora檔案 修改檔案的存取權限,管理員身份開啟, 修改檔案中的:Host:對應的資料為:自己電腦的IP: 如何修改:localhost 或者 127.0.0.1 或者 當前電腦的真是IP 1、查詢: 關鍵字 後面可以使用 select *、欄位列表、運算式、函數、查詢語句 from 表名、查詢語句、視圖列表 where (分組前)條件 group by 分組 having (分組後)條件 order by 排序 (升、降)2、Oracle中的4組模糊關鍵字 1、like、not like 2、is null、 is not null 3、between and 、not between and 4、in(a,b,c) not in(a,b,c)3、取別名:2中方式 1、欄位名 as 別名 舉例: select ename as 姓名 from emp;(推薦) select ename as "姓名" from emp;(不推薦) 2、欄位名 別名 舉例: select ename 姓名 from emp;(不推薦)4、資料的拼接: 拼接方式: 使用符號:|| 來拼接資料 舉例: select ‘姓名:‘||ename||‘,薪水:‘||sal as 員工薪水資訊 from emp; 結果顯示: 員工薪水資訊 姓名:Jason ,薪水:10000 姓名:Jack , 薪水:20000 ..... 說明: (1)Oracle中的資料拼接和Java中的資料拼接: Java中: 使用"+" Oracle中: 使用|| (2):只有在2中情況下常用單引號: 1、字元型資料 2、日期型資料5、排序:order by asc:升序 desc:降序 預設是asc升序 (1)、一次排序 使用: order by 欄位名 [asc/desc]; 或者 order by 運算式 [asc/desc]; (2)、二次排序: 使用: order by 欄位名1 [asc/desc],欄位名2 [asc/desc] ; 或者 order by 欄位名1 [asc/desc],運算式 [asc/desc]; 說明: Oracle中可排序的類型只有:數值型/日期型/字元型6、聯集查詢:union 說明: 1、聯合指的是表的上下拼接,不是列的拼接! 2、使用三個一致條件:(數量一致,類型一致,順序一致)。 3、最終顯示的列的列名按照第一個select的列為準! 使用舉例: select ename,sal as 薪水 from scott.emp where rownum<=2 union select ename as 姓名,sal from scott.emp; 查詢結果: ENAME 薪水 ADAMS 1100.00 ALLEN 1600.00 BLAKE 2850.00 CLARK 2450.00 FORD 3000.00 JAMES 950.007、查詢指定條數的資料: 關鍵字: rowid 行遊標的值,行的地址,在遍曆當前行之前就會有值! rownum 當前行的一個偽列, (偽列) 當查詢發生時產生,查詢結束時死亡! 特別說明: rownum:只能使用:<和<=, 並且只有在: select * from emp where rownum=1;這種情況下才能使用= 舉例: 需求:如何查取6-10行資料! SQL語句: select * from scott.emp where scott.emp.empno not in (select scott.emp.empno from scott.emp where rownum<=5) and rownum<=5; 資訊提取:分頁功能: select * from scott.emp where scott.emp.empno not in (select scott.emp.empno from scott.emp where rownum<=當前頁碼*每條顯示頁數) and rownum<=每頁條數;8、給表取別名: 方法很簡單: 格式: 表名 別名 特別注意: 在查詢語句中,對錶取別名之後,就不能再用表名了,應該用剛取好的別名!
資料庫(學習整理)----4--Oracle資料查詢(基礎點1)