標籤: select max(欄位1),over(partition by 欄位2,欄位3) from table ;--根據欄位2和欄位3分區取出欄位1的最大的相當於 select max(欄位1) from table group by 欄位2,欄位3;不過上面的sql會列出所有的行數,然後每一行多一個欄位,欄位值是一樣的這裡的max 可以相應的改成min,avg,sum() 等等 但是如果出現 select
標籤:1) select * from T1 where exists(select * from T2 where T1.a=T2.a) ; T1資料量小而T2資料量非常大時,T1<<T2 時,1) 的查詢效率高。2) select * from T1 where T1.a in (select T2.a from T2) ; T1資料量非常大而T2資料量小時,T1>>T2 時,2)
標籤:使用case...when語句進行判斷,其文法格式如下: case<selector>when<expression_1> then pl_sqlsentence_1;when<expression_2> then pl_sqlsentence_2;...when<expression_n> then pl_sqlsentence_n;[else plsql_sentence;]end case;具體例子如下:declare v_
標籤:1.首先以sysdba的身份登入上去 conn /as sysdba2.關閉資料庫shutdown immediate;3.以mount打來資料庫,startup mount4.設定session SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;SQL> ALTER SYSTEM SET
標籤: 情境:對2千萬個資料,修改他們的名字加上尾碼“生日”。普通sql: update calendar_info set title =concat(title, ‘生日‘) where specialtype = 1 and not regexp_like(title, ‘生日‘);最佳化sql:declaretype rid_Array is table of rowid index by binary_integer;v_rid
標籤:1、如果order by columnA,那麼在where查詢條件中添加條件columnA=value,則oracle內部會過濾order by排序,直接用索引。2、如果order by columnA,columnB,那麼在where查詢條件中添加條件columnA=value1,columnB=value1,則oracle內部會過濾order by排序,直接用索引。3、如果order by