1. 請注意運算子的優先順序,情況複雜的,多用括號以明晰邏輯。
notice: precedence of operator! please don't stint '(' and ')' if you can't clarify the situation.
2. 需要根據某字段為空來查詢記錄:
select condition: some section value is null in some table
select * from table_x t where t.section_a is null;
3. 修改表中記錄:
update some record in some table:
update table_x set section_a = '***' , section_b = 'yyy' where section_c = 'zzz';
4. 刪除表中記錄:
delete some record(s) in a table:
delete table_x where section_a = '***';
5. nvl函式,其作用是:如果第乙個引數為空值,則返回第二個引數的值,否則返回第乙個引數的值。
function 'nvl': if the first parameter is null, the second para as the return value; else return the first parameter.
6. 在執行一了些資料插入或刪除之後,與ms sql server不同,oracle中需要提交剛才執行的結果(可通過 commit; 語句實現)。
7. psu.end_date is null or psu.end_date > sysdate 判空,以及比較時間,關鍵字"is"和">"。
8. upper(psu.user_code)=upper('%s') 都以大寫來比較,類似的,c++中有uppercase函式。
9. 根據表中已有資料,建立一條「類似」資料並插入:??
10.select to_char(0.8, '0.0')||'%' from dual 查詢結果是字串:0.8%
oracle中用SQL語句對某張表進行備份還原
1.備份跟原表一樣的資料 select into ct rec questions beif from ct rec questions 2.還原表結構一模一樣的資料 insert into ct rec questions select from ct rec questions beif 3.還...
基於SQL語句的分頁
基於sql語句的分頁一般使用儲存過程實現。它通過編寫sql查詢,對資料進行篩選,僅返回當前頁面所需的資料內容。要進行分頁,首先必須要知道每頁顯示多少條 pagesize 要顯示第幾頁 pageindex 基於sql語句的分頁方式的優勢在於每次返回資料量較少 僅返回當前頁所需的資料內容 適合大資料量的...
Oracle常用的SQL語句
1 資料庫的操作 1 建立資料庫 語法 create database dbname 2 刪除資料庫 語法 drop database dbname 2 建立資料庫使用者 oracle內部有兩個建好的使用者 system和sys。使用者可直接登入到system使用者以建立其他使用者,system是系...