Você está na página 1de 5

2/3/2017 CharacterFunctions()Testingpool

CharacterFunctions()
testingpool.com/characterfunctions/

ByShikhaKatariya 9/26/2015

SampleDatabase:

TherearefollowingCharacterFunctions().

1.INITCAP()

ItconvertstheInitialletterofeverywordintoUpperCaseandrestinLowercase.Thischangesareonlytemporaryanddoneonlyinthebuffer.

Syntax:INITCAP(orString)

Example:

Ques:ConvertEnameofEMPTableintoProperCase

http://testingpool.com/characterfunctions/ 1/5
2/3/2017 CharacterFunctions()Testingpool

Ques:ConvertstringuttarpRADESHintopropercase.

Soln:SELECTINITCAP(uttarpRADESH)FROMDUAL

OutputUttarPradesh

2.LTRIM()

Ittrimsthespacesifpresentfromtheleftsideofthestring.

Syntax:LTRIM(orString)

http://testingpool.com/characterfunctions/ 2/5
2/3/2017 CharacterFunctions()Testingpool

Example:

Ques:RemovethespacesfromEnamecolumnofEMPtable

Soln:SELECTLTRIM(ENAME)FROMEMP

Ques:RemovethespaceinApple.

Soln:SELECTLTRIM(Apple)FROMDUAL

OutputApple

3.RTRIM()

Ittrimsthespacesifpresentfromtherightsideofthestring.

Syntax:RTRIM(orString)

Example:

Ques:RemovetherightspacesfromEnamecolumnofEMPtable

Soln:SELECTRTRIM(ENAME)FROMEMP

Ques:RemovethespaceinApple.

Soln:SELECTLTRIM(Apple)FROMDUAL

OutputApple

4.TRIM()

Ittrimsthespacesifpresentfromthebothsidesofthestring.

Syntax:TRIM(orString)

Example:

http://testingpool.com/characterfunctions/ 3/5
2/3/2017 CharacterFunctions()Testingpool

Ques:RemovethespacesfromEnamecolumnofEMPtable

Soln:SELECTTRIM(ENAME)FROMEMP

Ques:RemovethespaceinApple

Soln:SELECTTRIM(Apple)FROMDUAL

OutputApple

5.UPPER()

Itisusedtoconvertallthecharactersofthestringintouppercase.

Syntax:UPPER(<Columnname>orString)

Example:

Ques:Displaythenameofalltheemployeesinuppercase.

Soln:SELECTUPPER(ENAME)FROMEMP

Ques:Convertthestringstrawberryintouppercase.

Soln:SELECTUPPER(strawberry)ROMDUAL

Output:STRAWBERRY

6.LOWER()

Itisusedtoconvertallthecharactersofthestringintolowercase.

Syntax:LOWER(<Columnname>orString)

Example:

Ques:Displaythenameofalltheemployeesinuppercase.

http://testingpool.com/characterfunctions/ 4/5
2/3/2017 CharacterFunctions()Testingpool

Soln:SELECTLOWER(ENAME)FROMEMP

Ques:Convertthestringstrawberryintouppercase.

Soln:SELECTUPPER(STRAWberry)ROMDUAL

Output:strawberry

7.LENGTH()

Itisusedtodeterminethelengthofthespecifiedcolumnorstring.Ifthestringcontainsspaces,thenitisalsocountedasspacehasaASCIIvalue
associatedwithit.

Note:IfthecolumnvalueisofdatatypeCHAR(asCHARisfixedlength)thenitreturnsthefixedlengthdefinedirrespectiveoftheactual
lengthofthevaluepresent.Ontheotherhandifthecolumnvalueisofdatatypevarchar2(varcharisofvariablelength)thenitreturnsthe
actuallengthofthevaluepresent.

Syntax:LENGTH(<Columnname>orString)

Example:

Ques:Displaythelengthofthenamesofalltheemployees.(assumedatatypeofENAMEcolumnisCHAR(10)

Soln:SELECTLENGTH(ENAME)FROMEMP

Ques:Displaythelengthofthenamesofalltheemployees.(assumedatatypeofENAMEcolumnisVARCHAR2(10)

Soln:SELECTUPPER(STRAWberry)ROMDUAL

Output:strawberry

Testingpool2015.AllRightsReserved

http://testingpool.com/characterfunctions/ 5/5

Você também pode gostar