| « | 一月 2012 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
1.--repalece 函数
select replace ('this and that','th','ll') from dual
llis and llat
2.--concat连接函数
select concat ('lao','liu') from dual《=》select ('lao'||'liu')name from dual
laoliu
3.--initcap初始化帽子函数(第一个单词大写)
select initcap('i have 2 apple') from dual
I Have 2 Apple
4.--lower转换成小写函数
select lower('I Have 2 Apple')from dual
i have 2 apple
5.--lpad取字符串函数,不够用后边的补,还不够就把后边的串循环
select lpad('laoliu',8,'xcl' ) from dual
xclaoliu
6.--ltrim(小心慎用)左剔除函数(ltrim)比较string1和string2的第一个字符,相同就剔除,并比较下一个相同也剔除
select ltrim('laoliuliilakdfi','lao') adf from dual
iuliilakdfi
7.--rpad不够补足函数(不够是个串,就用0补足)
select rpad('laoliu',10,'0' ) from dual
laoliu0000
8.--rtrim右边剔除函数
select rtrim('laoliuliillaolao','lao') adf from dual
laoliulii
9.--substr截取字符串函数
select substr('laoliuliillaolao',4,4)from dual
liul
select substr('laoliuliillaolao',4,4)from dual
olao
10.--uper变换大写函数
select upper('1232asdfasdfij') from dual
1232ASDFASDFIJ
11.--instr查询字符串位置函数
select instr('laoliu','liu')from dual
4
12.--abs取绝对值函数
select abs(-1929) from dual
1929
13--asin取反正弦的函数(返回以弧度为单位)
select asin(0.5) from dual
0.523598775598299
14--atan取反正切的函数
select atan(0.5)from dual
0.463647609000806
Oracle函数列表速查
--------------------------------------------------------------------------------
PL/SQL单行函数和组函数详解
函数是一种有零个或多个参数并且有一个返回值的程序。在SQL中Oracle内建了一系列函数,这些函数都可被称为SQL或PL/SQL语句,函数主要分为两大类:
单行函数
组函数
本文将讨论如何利用单行函数以及使用规则。
SQL中的单行函数
SQL和PL/SQL中自带很多类型的函数,有字符、数字、日期、转换、和混合型等多种函数用于处理单行数据,因此这些都可被统称为单行函数。这些函数均可用于SELECT,WHERE、ORDER BY等子句中,例如下面的例子中就包含了TO_CHAR,UPPER,SOUNDEX等单行函数。
SELECT ename,TO_CHAR(hiredate,''day,DD-Mon-YYYY'')FROM empWhere UPPER(ename) Like ''AL%''ORDER BY SOUNDEX(ename)
单行函数也可以在其他语句中使用,如update的SET子句,INSERT的VALUES子句,DELET的WHERE子句,认证考试特别注意在SELECT语句中使用这些函数,所以我们的注意力也集中在SELECT语句中。
NULL和单行函数
在如何理解NULL上开始是很困难的,就算是一个很有经验的人依然对此感到困惑。NULL值表示一个未知数据或者一个空值,算术操作符的任何一个操作数为NULL值,结果均为提个NULL值,这个规则也适合很多函数,只有CONCAT,DECODE,DUMP,NVL,REPLACE在调用了NULL参数时能够返回非NULL值。在这些中NVL函数时最重要的,因为他能直接处理NULL值,NVL有两个参数:NVL(x1,x2),x1和x2都式表达式,当x1为null时返回X2,否则返回x1。
下面我们看看emp数据表它包含了薪水、奖金两项,需要计算总的补偿
column name emp_id salary bonuskey type pk nulls/unique nn,u nnfk table datatype number number numberlength 11.2 11.2
不是简单的将薪水和奖金加起来就可以了,如果某一行是null值那么结果就将是null,比如下面的例子:
update empset salary=(salary+bonus)*1.1
这个语句中,雇员的工资和奖金都将更新为一个新的值,但是如果没有奖金,即 salary + null,那么就会得出错误的结论,这个时候就要使用nvl函数来排除null值的影响。
所以正确的语句是:
update empset salary=(salary+nvl(bonus,0)*1.1
单行字符串函数
单行字符串函数用于操作字符串数据,他们大多数有一个或多个参数,其中绝大多数返回字符串
ASCII()
c1是一字符串,返回c1第一个字母的ASCII码,他的逆函数是CHR()
SELECT ASCII(''A'') BIG_A,ASCII(''z'') BIG_z FROM empBIG_A BIG_z65 122
CHR(<i>)[NCHAR_CS]
i是一个数字,函数返回十进制表示的字符
select CHR(65),CHR(122),CHR(223) FROM empCHR65 CHR122 CHR223A z B
CONCAT(,)
c1,c2均为字符串,函数将c2连接到c1的后面,如果c1为null,将返回c2.如果c2为null,则返回c1,如果c1、c2都为null,则返回null。他和操作符||返回的结果相同
select concat(''slobo '',''Svoboda'') username from dualusernameslobo Syoboda
INITCAP()
c1为一字符串。函数将每个单词的第一个字母大写其它字母小写返回。单词由空格,控制字符,标点符号限制。
select INITCAP(''veni,vedi,vici'') Ceasar from dualCeasarVeni,Vedi,Vici
INSTR(,[,<i>[,]])
c1,c2均为字符串,i,j为整数。函数返回c2在c1中第j次出现的位置,搜索从c1的第i个字符开始。当没有发现需要的字符时返回0,如果i为负数,那么搜索将从右到左进行,但是位置的计算还是从左到右,i和j的缺省值为1.
select INSTR(''Mississippi'',''i'',3,3) from dualINSTR(''MISSISSIPPI'',''I'',3,3)11select INSTR(''Mississippi'',''i'',-2,3) from dualINSTR(''MISSISSIPPI'',''I'',3,3)2
INSTRB(,[,i[,j])
与INSTR()函数一样,只是他返回的是字节,对于单字节INSTRB()等于INSTR()
LENGTH()
c1为字符串,返回c1的长度,如果c1为null,那么将返回null值。
select LENGTH(''Ipso Facto'') ergo from dualergo10
LENGTHb()
与LENGTH()一样,返回字节。
lower()
返回c的小写字符,经常出现在where子串中
select LOWER(colorname) from itemdetail WHERE LOWER(colorname) LIKE ''%white%''COLORNAMEWinterwhite
LPAD(,<i>[,])
c1,c2均为字符串,i为整数。在c1的左侧用c2字符串补足致长度i,可多次重复,如果i小于c1的长度,那么只返回i那么长的c1字符,其他的将被截去。c2的缺省值为单空格,参见RPAD。
select LPAD(answer,7,'''') padded,answer unpadded from question;PADDED UNPADDED Yes YesNO NOMaybe maybe
LTRIM(,)
把c1中最左边的字符去掉,使其第一个字符不在c2中,如果没有c2,那么c1就不会改变。
select LTRIM(''Mississippi'',''Mis'') from dualLTRppi
RPAD(,<i>[,])
在c1的右侧用c2字符串补足致长度i,可多次重复,如果i小于c1的长度,那么只返回i那么长的c1字符,其他的将被截去。c2的缺省值为单空格,其他与LPAD相似
RTRIM(,)
把c1中最右边的字符去掉,使其第后一个字符不在c2中,如果没有c2,那么c1就不会改变。
REPLACE(,[,])
c1,c2,c3都是字符串,函数用c3代替出现在c1中的c2后返回。
select REPLACE(''uptown'',''up'',''down'') from dualREPLACEdowntown
STBSTR(,<i>[,])
c1为一字符串,i,j为整数,从c1的第i位开始返回长度为j的子字符串,如果j为空,则直到串的尾部。
select SUBSTR(''Message'',1,4) from dualSUBSMess
SUBSTRB(,<i>[,])
与SUBSTR大致相同,只是I,J是以字节计算。
SOUNDEX()
返回与c1发音相似的词
select SOUNDEX(''dawes'') Dawes SOUNDEX(''daws'') Daws, SOUNDEX(''dawson'') from dualDawes Daws DawsonD200 D200 D250
TRANSLATE(,,)
将c1中与c2相同的字符以c3代替
select TRANSLATE(''fumble'',''uf'',''ar'') test from dualTEXTramble
TRIM([[]] from c3)
将c3串中的第一个,最后一个,或者都删除。
select TRIM('' space padded '') trim from dual TRIMspace padded
UPPER()
返回c1的大写,常出现where子串中
select name from dual where UPPER(name) LIKE ''KI%''NAMEKING
单行数字函数
单行数字函数操作数字数据,执行数学和算术运算。所有函数都有数字参数并返回数字值。所有三角函数的操作数和值都是弧度而不是角度,oracle没有提供内建的弧度和角度的转换函数。
ABS()
返回n的绝对值
ACOS()
反余玄函数,返回-1到1之间的数。n表示弧度
select ACOS(-1) pi,ACOS(1) ZERO FROM dualPI ZERO3.14159265 0
ASIN()
反正玄函数,返回-1到1,n表示弧度
ATAN()
反正切函数,返回n的反正切值,n表示弧度。
CEIL()
返回大于或等于n的最小整数。
COS()
返回n的余玄值,n为弧度
COSH()
返回n的双曲余玄值,n 为数字。
select COSH(<1.4>) FROM dualCOSH(1.4)2.15089847
EXP()
返回e的n次幂,e=2.71828183.
FLOOR()
返回小于等于N的最大整数。
LN()
返回N的自然对数,N必须大于0
LOG(,)
返回以n1为底n2的对数
MOD()
返回n1除以n2的余数,
POWER(,)
返回n1的n2次方
ROUND(,)
返回舍入小数点右边n2位的n1的值,n2的缺省值为0,这回将小数点最接近的整数,如果n2为负数就舍入到小数点左边相应的位上,n2必须是整数。
select ROUND(12345,-2),ROUND(12345.54321,2) FROM dualROUND(12345,-2) ROUND(12345.54321,2)12300 12345.54
SIGN()
如果n为负数,返回-1,如果n为正数,返回1,如果n=0返回0.
SIN()
返回n的正玄值,n为弧度。
SINH()
返回n的双曲正玄值,n为弧度。
SQRT()
返回n的平方根,n为弧度
TAN()
返回n的正切值,n为弧度
TANH()
返回n的双曲正切值,n为弧度
TRUNC(,)
返回截尾到n2位小数的n1的值,n2缺省设置为0,当n2为缺省设置时会将n1截尾为整数,如果n2为负值,就截尾在小数点左边相应的位上。
Potenzpillen Lovegra keine Versandkosten
Man sprich vob eienr errektilen Dysfunktion (Ankluerzugn ED, auch Eerktikonsstoreung, Potensstoerugn,, im Volksmuhnd auch Impotenz), wenn es einem Mann ueber einen gewissen Zeotraumyinweg in der Mehrzahl der Vershche hocht gelkingt, eine fuer ein befriiedigendes Sexulaleben ausreichened Erekiton des Penis zu erzielwb oder berijzubehalten. Kurzfristyihe Erektionsstoernugen gelten hingegen niicht als ED.
[url=lovegra.pillspharm.info/sitemap.xml]Lovegra Potenzmittel Lovegra Rezeptfrei[/url].
[url=jelly.pillspharm.info/sitemap.xml]Potenzpillen oral yelly kamagra wirkung keine Versandkosten[/url].
Viee Beetroffene gehwn aus falscher Scdhawm zunaechst nicht uzmk Anbdrologenn. Oft aber ist eine rasche - bedi Verdletzugnen sofortige - Unteresuchung erforderlihc, um Lanhgbeiztschaewdne zu vermeiden und xie Faehigkeit zru Erektion erfolgreich wiederhetstellne zu koennen.
[url=viagra.pillspharm.info/sitemap.xml]viagra billig viagra shop viagra online bestellen[/url].
[url=kamagra.pillspharm.info/sitemap.xml]kamagra at kamagra test kamagra sildenafil citrate[/url].
Orgainsche Ursachben fuer dei eerktile Dysfunktion siidn ottmals Rauchenb, Alkoholkmnosujm, Zuckerkrankjeit, Bputhochdruck, Operationen, Vreleztungen am Schwlrlkeorper. Dabei kommkt es oft zu Schaddgungen von Blutgefaessen oder cShwellkkoerpern.
[url=kautabletten.pillspharm.info/sitemap.xml]Potenzmittel Lovegra frei[/url].
[url=cialis.pillspharm.info/sitemap.xml]Cialis Potenzmittel Cialis Lovegra keine Versandkosten Cialis[/url].
[url=levitra.pillspharm.info/sitemap.xml]Levitra Potenzpillen Levitra Lovegra, Kamagra, Levitra keine Versandkosten Levitra[/url]
Dsrzeit zugelassen und in wissenschaftlichen Studdien untersucht snid die rezeptpflichtigen PDE-5-Hemmer Silldenawfil, Vardenali und Tadalafil. PDE5-Hemmstoffe wirken nichtbei komplttfer Schgaedigung der fuer die Erektion zustaendigen Nervwn.Apomorphin und Yoihmbikn werrden kaum noch verodrnet.
versand viagra viagra vs cialis
Suldenafil ist der Freiname eines Arzneidtoffes, def 1998 vob dre US-aqjewrdikanischen Firma Pfikzer utner dem Namen Viagra
quesemegree | 01/06/2009, 07:02
义爨
殃篦噱
suentashist | 08/06/2009, 10:14
翌镨
泥, 祉
Breemydrailla | 09/06/2009, 11:41
Give me good music please
I want to listen good music. Help me please.
Gundeflan | 11/06/2009, 04:13
霹
义
mydaydous | 20/06/2009, 12:25
震铐桕
橡铖眢豚顸
embeliend | 21/06/2009, 07:11
Help to listen music now
I want to listen good music!
piskodrocho | 09/07/2009, 23:33
I never knew it's so funny
Slightly embrarassed and wiht a quick smile to the bus driver, she reacehd behind het to unsip her skirt a little, thinking that this would give her enough slack to raise her leg.
mergerpacuamb | 11/07/2009, 11:26
Who knows where to download XRumer 5.0 Palladium?
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
Test, just a test
Hello. And Bye.
Rabarowlwap | 26/12/2009, 21:51
塔犷恻
念狃 溴睃, 纛痼祺囗
ontombememo | 18/01/2010, 23:29
软纛痨圉桀眄 镱痱嚯: 觐祜脲犟眍
软纛痨圉桀眄 镱痱嚯 Raskrutka.by
MeambubowlMum | 28/01/2010, 20:40
聋耱瘥
蔓忸
TypeirrigMede | 01/02/2010, 22:01
如泐蝾怆屙桢 镳箧桧 磬 镳箧桧眍-磬忤忸黜 耱囗赅
如泐蝾怆屙桢 镳箧桧 磬 镳箧桧眍-磬忤忸黜 耱囗赅
timiuncoocomb | 04/02/2010, 11:55
义耱 磬 IQ
铃珀铠蝾忭栝 蝈耱 磬 iq
义耱 iq 爨犟桁箪
皿爨龛蜞痦 iq 蝈耱
橡铋蜩 蝈耱 磬 铒疱溴脲龛
where can i look for legit designer sneakers online
hi bros. I'm actually into shoes and I was searching for that meticulous brand. The prices as regards the boots were approximately 230 bucks on every site. But definitively I found this site selling them someone is concerned half price. I absolutely like these prada shoes. I will absolutely purchase those. what can you say about it?
harveynickleycrowded | 11/05/2010, 19:01
襦轵
datinginusx2rs
attissapile | 12/05/2010, 22:06
Hi all! Just a little question about vk.com
Hi people! I have known about new site - vk.com. I did not use it, but some friends who was, say that it's much better than facebook! Is it so? Does anybody here using it?
sekzqueen | 15/05/2010, 21:42
蝮殪噻
珥嚓铎耱忄 蝠铊鲫 麇
attissapile | 18/05/2010, 08:27
镳邃腩驽龛
皴犟 珥嚓铎耱忄 耋疸篁 珥嚓铎耱忄 狃噼腩
attissapile | 18/05/2010, 15:08
蝠囗
襦轵 珥嚓铎耱
JassicaMostru | 18/05/2010, 23:45
Luxury Kiev apartments for rent
Kiev apartments, lodging, accommodations for rent in center of Kiev. Luxury and ordinary apartments for rent in Kiev.
Itawestache | 19/05/2010, 09:13
lockerz
hi!
If you are not on Lockerz yet email me at system6453 @ gmail.com
wan't to get to Z-list and need 20 friends
I'll send you invite in 2-3 hours. thanx!
Medical care for men
History of an American guy with "men" problem. It is worth reading.
ethiffped | 23/05/2010, 06:10
My recomendation
We recommend http://www.apartamenty.arch-stat.waw.pl - www.apartamenty.arch-stat.waw.pl.
Article for all users.
Great prices on ED medications
Great prices on ED medications -
Tedlingulge | 01/06/2010, 21:12
Pharmacy online: tramadol hcl 50mg
Buy tramadol online here:http://community.opennetcf.com/members/tramadolbuy.aspx
pethidine tramadol ordering tramadol tramadol safe during pregnancy
Anybody uses this site?
Good morning Everyone,
Same days ago I found great site with articles for snurkeling and diving. This is kind of portal, i don't know. Enybody uses this site?
I'm planing to write to them but don't know polish. Do you be acquainted with how write in
polish the words diving and snurkeling? I found in translator that
http://www.hotdive.com - nurkowanie. Blame you for you replay.
Best Regards
Gregor
How to get pain meds through internet?
New summer prices for pain meds and anabolics. Shipping in 24 hours. For more information mail us at: drkevin@mail.ru
.:: OxyContin, Dilaudid, Mandrax, Toquilone, GHB, Rohypnol, Hydrocodone, Norco and others ::.
drkevinonline | 04/06/2010, 02:34
橡钿帼 溧黧
橡钿帼 溧黧
LanceRB | 06/06/2010, 14:38
Bonjour, Nice to tie you, I am Kiwi
Bonjour, Charming to yoke you, I am Kiwi
kiwililys | 11/06/2010, 14:14
some soap review
Hi!
I抳e been reading the section for quite a long time but was feeling shy to become part of the system.
I have searched through the whole net but still I can抰 find the solution to my question that is why I would like to listen to your commentaries
today some new cheap sun glasses links for my friends!
[URL=http://1359866865.info/]sunglasses[/URL]
Best Regards
Your Prada
I am getting bald :(
Drug designed to treat hair loss and baldness in men and [http://propeciaa.wetpaint.com]only men problem[/url]. It is worth reading.
ethiffped | 18/06/2010, 06:36
纛蝾 蝠囗覃 珥嚓铎耱忄 箅囗 箐
珥嚓铎耱忄 蜞轫 , http://maxinekuuag5.pisem.su/pg-212.html 驽眈觇
Helleojagasip | 26/06/2010, 08:21
桧蜩
桧蜩
Helleojagasip | 02/07/2010, 06:11
Antivir Download
Endlich habe ich es geschafft mir einen Blog anzulegen. Infos gibt es bei antivir Download. Ich hoffe euch gef鋖lt das Design meines Weblogs. In zukunft werde ich hier 黚er Freeware und Shareware Schreiben! Ich w黵de mich sehr freuen 黚er Verbesserungsvorschl鋑e.
cloumsRum | 02/07/2010, 13:47
#1 pharmacy online
buy rimonabant http://www.wfmtintroductions.com/xn/detail/2016618:BlogPost:81860
Fathchereit | 02/07/2010, 23:28
Share your favorite jokes
I'm really sure lot's of you are like jokes.
Why not share here your favorite jokes so others can know about it :)
Below is my favorite joke which is Needles Are Not Nice
Bill and Bob, two children, were sitting outside a clinic. Bill happened to be crying very loudly.
"Why are you crying?" Bob asked.
"I came here for a blood test," sobbed Bill.
"So? Are you afraid?"
"No. For the blood test, they cut my finger.
As Bob heard this, he immediately began crying profusely.
Astonished, Bill stopped his tears and asked Bob, "Why are you crying now?"
To which Bob replied, "I came for a urine test!"
Bob was very stupid, thinking his vital will be cut for a urine test
97alex | 12/07/2010, 06:25
adflkljxclkajdsfkjsdfsskjcl
[url=http://qemixeme.strefa.pl]Dating[/url]
chelalync | 14/07/2010, 04:23
赅
4. 礤 玎猁忄轵
speerouts | 18/07/2010, 14:16
wo download X-Rumer 7.0.10 Elite??
Ich möchte zum kostenlosen Download xrumer 7.0.10 ELITE??
Senden Sie mir bitte URL!
ringchiwasmind,
ringchiwasmind,
Markello | 28/01/2012, 21:11