0% found this document useful (0 votes)
41 views7 pages

Dbms Lab (Experiment - 1) : 1. Single Row Numeric Functions A) ABS

The document describes various single row numeric and character functions in Oracle SQL such as ABS(), CEIL(), FLOOR(), MOD(), POWER(), ROUND(), SIGN(), SQRT(), TRUNC(), SIN(), COS(), EXP(), LN(), CHR(), LOWER(), UPPER(), INITCAP(), LPAD(), RPAD(), RTRIM(), LTRIM(), SUBSTR(), REPLACE(), TRANSLATE(), CONCAT(), INSTR(), ASCII(), LENGTH(), and REVERSE(). Each function is explained along with its syntax and an example query demonstrating its usage and output.

Uploaded by

sarala devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views7 pages

Dbms Lab (Experiment - 1) : 1. Single Row Numeric Functions A) ABS

The document describes various single row numeric and character functions in Oracle SQL such as ABS(), CEIL(), FLOOR(), MOD(), POWER(), ROUND(), SIGN(), SQRT(), TRUNC(), SIN(), COS(), EXP(), LN(), CHR(), LOWER(), UPPER(), INITCAP(), LPAD(), RPAD(), RTRIM(), LTRIM(), SUBSTR(), REPLACE(), TRANSLATE(), CONCAT(), INSTR(), ASCII(), LENGTH(), and REVERSE(). Each function is explained along with its syntax and an example query demonstrating its usage and output.

Uploaded by

sarala devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DBMS LAB

(EXPERIMENT _1)
1. SINGLE ROW NUMERIC FUNCTIONS

a) ABS ( )

Description : The ABS( ) function returns absolute value of a member .


Syntax : ABS(number)
Example Query : select ABS(-12) from dual;
Output :

b) CEIL( )

Description : The CEIL( ) function returns the smallest integer value that is larger
than or equal to that number.
Syntax : CEIL(number)
Example Query : select CEIL(-25.7) from dual;
Output :

c) FLOOR ( )

Description : The FLOOR( ) function returns largest integer value that is smaller
than or equal to a number.
Syntax : FLOOR(number)
Example Query : select FLOOR(-28.7) from dual;
Output :

d) MOD( )

Description : The MOD( ) function returns the remainder when first number is
divided by second.
Syntax : MOD(dividend,divisor)
Example Query : select MOD(19,3) from dual;
Output :
e) POWER ( )

Description : The POWER( ) function returns the value when a number n is raised
to a power x .
Syntax : POWER(base,exponent)
Example Query : select POWER(2,3) from dual;
Output :

f) ROUND ( )

Description : The ROUND( ) function rounds a number to a specified number of


decimal places.
Syntax : ROUND(number,decimal)
Example Query : select ROUND(33.951) from dual;
Output :

g) SIGN ( )

Description : The SIGN( ) function returns the sign of a number.It returns


i) 0 if number=0
ii) 1 if number >0
iii) -1 if number <0
Syntax : SIGN(number)
Example Query : select SIGN(12) from dual;
Output :

h) SQRT ( )

Description : The SQRT( ) function returns the square root of the number. If the
number is irrational, it displays upto 38 decimals.
Syntax : SQRT(number)
Example Query : select SQRT(13) from dual;
Output :

i) TRUNC ( )

Description : The TRUNC( ) function returns n1 truncated to n2 decimal places.If


n2 is omitted, n1 is truncated to 0 places. N2 can be negative to
truncate to n2 digits left of the decimal point.
Syntax : TRUNC(number,decimal places)
Example Query : select TRUNC(15.777,-1) from dual;

Output :

j) SIN ( )

Description : The SIN( ) function returns the sine value for x radians.
Syntax : SIN(x)
Example Query : select SIN(1.567) from dual;
Output :

k) COS ( )

Description : The COS( ) function returns the cosine value for x radians.
Syntax : COS(x)
Example Query : select COS(1.567) from dual;
Output :

l) EXP ( )

Description : The EXP( ) function returns the exponential value of x


Syntax : EXP(x)
Example Query : select exp(2) from dual;
Output :

m) LN ( )

Description : The LN( ) function returns the natural logarithm value of x.


Syntax : LN(x)
Example Query : select ln(2.7) from dual;
Output :
2. SINGLE ROW CHARACTER FUNCTIONS

a) CHR( )

Description :CHR( ) function converts any numerical value into its equivalent
ASCII Character.
Syntax : CHR(ASCII Code)
Example Query : select CHR(116) from dual;
Output :

b) LOWER( )

Description : LOWER( ) function converts all the uppercase characters in the


given string to lower case characters.
Syntax : LOWER(string)
Example Query : select LOWER('PANDU') from dual;
Output :

c) UPPER( )

Description : UPPER( ) function converts all the lowercase characters in the


given string to uppercase characters.
Syntax : UPPER(ASCII Code)
Example Query : select UPPER('pandu') from dual;
Output :

d) INITCAP( )

Description : INITCAP( ) function converts the first letter of each word in a


string to uppercase and converts any remaining characters in each
word to lowercase. Words are delimited by white-space or by
characters that are not alphanumeric.
Syntax : INITCAP(Expression)
Example Query : select INITCAP('pandu is a good girl') from dual;
Output :
e) LPAD( )

Description :It is used in padding the left side of a string with a specific set of
characters useful for formatting the output of a query. A number
indicating the total length of the string is returned after padding.
Syntax : LPAD(string,length,character(s))
Example Query : select LPAD('pandu',10,'xy') from dual;
Output :

f) RPAD( )

Description :It is used in padding the right side of a string with a specific set of
characters useful for formatting the output of a query. A number
indicating the total length of the string is returned after padding.
Syntax : RPAD(string,length,character(s))
Example Query : select RPAD('pandu',10,'xy') from dual;
Output :

g) RTRIM( )

Description :It returns the string by removing trim_string from the right of the
given and string .
Syntax : RTRIM(string[,trim_string] )
Example Query : select RTRIM('PANDU','U') from dual;
Output :

h) LTRIM( )

Description : It returns the string by removing trim_string from the left of the
given and string .
Syntax : LTRIM(string,[trim_string] )
Example Query : select LTRIM('PANDU','PA') from dual;
Output :

i) SUBSTR( )

Description : It allows us to extract substring from astring.


Syntax : SUBSTR(string,start_position[,length])
Example Query : select substr('Pandu is an good girl',4,10) from dual;
Output :

j) REPLACE( )

Description : Replaces a sequences of character in a string with other set of


characters.
Syntax : REPLACE(string1,string_to_replace,replacement_string )
Example Query : select REPLACE('SQL tutorial','tu','HTML') from dual;
Output :

k) TRANSLATE( )

Description :It replaces a sequence of characters in a string with another set of


characters. However , it replaces a single character at a time.
For example,It will replace first character in the srting_to_replace
with the first character in the replacement string. Then it will replace
the second character and so on.
Syntax : TRANSLATE(string1,atring_to_replace,replacement_string)
Example Query : select TRANSLATE('SQL tutorial','t','HTML') from dual;
Output :

l) CONCAT( )

Description : CONCAT( ) functions converts any numerical value into its


equivalent ASCII Character.
Syntax : CONCAT(expression1,expression2)
Example Query :
1) select concat('new','york') from dual;
2) select 23.5||34.5 from dual;

Output :

1)

2)
m) INSTR( )

Description : INSTR( ) function returns the position of the character in


expression1 that is the first character of the search string.
Syntax : INSTR(expression 1, search string, position, occurrence)
1) If position<0, oracle counts backward from the end of expression1
and searches backward from resulting position.
2) Occurrence represents which occurrence of expression 1 should be
searched. It should be greater than 0.
Example Query : select INSTR('corporate floor','or',-3,1) from dual;
Output :

n) ASCII( )

Description : It returns decimal representation in database character set of the


first character of the expression.
Syntax : ASCII(expression)
Example Query : select ASCII('cse') from dual;
Output :

o) LENGTH( )

Description : It returns the length of the expression.


Syntax : LENGTH(expression)
Example Query : select LENGTH('cbit college') from dual;
Output :

p) REVERSE( )

Description : It reverses the string and returns the result.


Syntax : REVERSE(expression)
Example Query : select REVERSE('cbit college') from dual;
Output :

You might also like