PLSQL常用方法彙總

2021-08-29 19:26:46 字數 2446 閱讀 4422

在sqlplus下,實現中-英字符集轉換oracle學習網mm:ict2oc!n)^

alter session set nls_language='american';

1r il e g,w;oh#u)ic7m~

insert into test select * from dept;oracle學習網 c-h&?ya&n om+p

二、運算子oracle學習網2b#jmu m4y q8ba

算術運算子:+ - * / 可以在select 語句中使用oracle學習網9x(m,ul x ~7d

連線運算子:|| select deptno|| dname from dept;

5[w!w x f~集合運算子: intersect ,union, union all, minus oracle學習網'k~idb^6bt0d?b}

要求:對應集合的列數和資料型別相同

!t$z v?s0e ]:~c查詢中不能包含long 列oracle學習網n3si9}'w

列的標籤是第乙個集合的標籤

d)f3vbv#b使用order by時,必須使用位置序號,不能使用列名oracle學習網&u/y6lnmt'k.l r;o

例:集合運算子的使用:

bo ]8`z?&ointersect ,union, union all, minus

7r(m[v [

select * from emp where deptno=10 union all select * from emp where deptno in (10,20); --包括重複行

mp&m4u&jc

}#k3x.|gwubn三,常用 oracle 函式

1`0t|n*wj0xq.e%bsysdate為系統日期 dual為虛表

^6ar2`g.]8o一)日期函式[重點掌握前四個日期函式]

rsrbq0z7_~@\q1,add_months[返回日期加(減)指定月份後(前)的日期]

f"p3a/pbg+aiv3yselect sysdate s1,add_months(sysdate,10) s2,oracle學習網#p2t1s1z5k

add_months(sysdate,5) s3 from dual;

?)e8zxx9r#e#m2,last_day [返回該月最後一天的日期]

0a7n+m ` vn9aselect last_day(sysdate) from dual;

r6op i6f?v^*e3,months_between[返回日期之間的月份數]

*w9i }r&eselect sysdate s1, months_between('1-4月-04',sysdate) s2,oracle學習網!e x"vm/leu

months_between('1-4月-04','1-2月-04') s3 from dual

i"c:x;d;x8te ag4,next_day(d,day): 返回下個星期的日期,day為1-7或星期日-星期六,1表示星期日

c$@p)mmv?)m^@ |select sysdate s1,next_day(sysdate,1) s2,oracle學習網3`(`(zd @

trim(trailing 9 from 9998767999) s2,

8r#a/ndq5?x-ptrim(9 from 9998767999) s3 from dual;

@e(gd6x9` ~8,initcap(首字母變大寫) ,lower(變小寫),upper(變大寫)

8b0s&w;ke)f)wselect lower('abc') s1,

0cl1rr-b/j`2}upper('def') s2,

,e.tt x^3g|/binitcap('efg') s3 from dual; oracle學習網`

select lpad('func',15,'=') s1, rpad('func',15,'-') s2 from dual;oracle學習網i1s:j \+wo

select lpad(dname,14,'=') from dept;

j r-ey2w i[g12, decode[實現if ..then 邏輯]

]:vb#n:ha]}-zselect deptno,decode(deptno,10,'1',20,'2',30,'3','其他') from dept;oracle學習網'_#y;j|sf w }o!a

三)數字函式oracle學習網~#~1w+hny

1,取整函式(ceil 向上取整,floor 向下取整)

9usc |},9`select round(66.667,2) n1,trunc(66.667,2) n2 from dual;

.gpb7z5zu5,返回值的符號(正數返回為1,負數為-1)

6q)a.x{*g a%nuselect sign(-32),sign(293) from dual;

NSString 常用方法彙總

stringwithcontentsoffile path encoding enc error err 建立乙個新字串並將其設定為path 指定的檔案的內容,使用字元編碼 enc,如果非零,則返回 err中錯誤 id stringwithcontentsofurl url encoding enc...

js常用方法彙總

產生在m n之間的隨機整數 把數四捨五入為最接近的整數。function random m,n console.log random 20,30 20 30之間整數 將乙個dom元素劃分成多個小塊生成乙個陣列 位置,專案數量,新專案 返回值 array 新陣列 返回元素的高 function ele...

python常用方法彙總

補齊 join random.sample zyxwvutsrqponmlkjihgfedcba0123456789 11 使用bool 只能將 空字串,none,0轉為false,其它為true,所以建議使用如下方法 def str2bool v return v.lower in yes tru...