[go: up one dir, main page]

0% found this document useful (0 votes)
14 views6 pages

DBMS 3

Uploaded by

pareshkumar3108
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)
14 views6 pages

DBMS 3

Uploaded by

pareshkumar3108
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/ 6

Exp No: Page No:

Date:

Experiment No:3
3.)Queries to facilitate acquaintance of Built-in Functions: String Functions,
Numeric Functions, Date Functions and Conversion Functions.
Aim: To facilitate acquaintance of Built-in Functions: String Functions, Numeric
Functions, Date Functions and Conversion Functions.

Description:
 String Functions:
Length():
This function is used to find the length of a word.

Syntax:
Select length(“String_name”) from dual;

Lower():
This function is used to convert the upper case string into lower case.
Syntax:
select lower(“string_name”) from dual;
LPAD():
This function is used to make the given string of the given sizeby adding the
given symbol.
Syntax:
select lpad(‘string_name’,num,’string’) from dual;

LTRIM():
This function is used to cut the given sub string from theoriginal string.
Syntax:
select ltrim(‘string_name’,’string’) from dual;

CONCAT():
This function is used to add two words or strings.

Syntax:
select concat(‘string_name’,’another_string’) from dual;

MID():
This function is to find a word from the given position and ofthe given size.
Syntax:
select mid(‘string_name’,num,num) from dual;

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A61A4


Exp No: Page No:
Date:

POSITION():
This function is used to find position of the first occurrence ofthe given
alphabet.
Syntax:
select position(‘character’ in ’string’) from dual;
REPEAT():
This function is used to write the given string again and againtill the number
of times mentioned.
Syntax:
select repeat(‘string_name’,num) from dual;

REPLACE():
This function is used to cut the given string by removing thegiven sub
string.
Syntax:
select replace (‘string_name’,’string’) from dual;
REVERSE ():
This function is used to reverse a string.
Syntax:
select reverse(‘string_name’) from dual;

RPAD():
This function is used to make the given string as long as thegiven size by
adding the given symbol on the right.
Syntax:
select rpad(‘string_name’,num,’string’) from dual;
RTRIM():
This function is used to cut the given sub string from the originalstring.
Syntax:
select rtrim(‘string_name’,’string’) from dual;
SUBSTR():
This function is used to find a sub string from the a string fromthe given
position.
Syntax:
Select substr(‘string_name’, start_index, end_index) from dual;

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A6184


Exp No: Page No:
Date:

Queries:
 LENGTH():

SQL> select length('satyanarayana') from dual;


LENGTH('SATYANARAYANA')
-----------------------
13

 LOWER ():

SQL> select lower ('REDDYS') from dual;

LOWER(
-----------------------
reddys

 LPAD():

SQL> select lpad (‘aditya’,8,’*’) from dual;

LPAD(‘AD
-----------------------
**aditya

 LTRIM():

SQL> select ltrim (‘****aditya’,’*’) from dual;

LTRIM(
-----------------------
Aditya
 CONCAT():
SQL> select concat(‘satya’,’narayana’) from dual;
CONCAT('SATYA
-------------
Satyanarayana
 REPLACE():
SQL> select replace('reddysatyareddy', 'reddy') from dual;
REPLA
-----

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A61A4


Exp No: Page No:
Date:

Satya
 REVERSE ():
SQL> select reverse('sydder') from dual;
REVERS
------
reddys

 RPAD():
SQL> select rpad('aditya',10,'*') from dual;
RPAD('ADIT
----------
aditya****
Numeric Functions:
 max():
To get the maximum value from the table in a column.
Syntax:
select max(<column_name>) from <table_name>;

 min():
To get the minimum value from the table in a column.

Syntax:
select min(<column_name>) from <table_name>;

 sum():
To get the addition of values from the table in a column.

Syntax:
select sum(<column_name>) from <table_name>;

 avg():
To get the average of values from the table in a column.

Syntax:
select avg(<column_name>) from <table_name>;

 ceil():
It round of the decimal value to the next value.
Syntax:
select ceil(<decimal value>) from dual;

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A61A4


Exp No: Page No:
Date:

 floor():
It round of the decimal value to the below value.
Syntax:
select floor(<decimal value>) from dual;

Queries:
 max():
SQL> select max(age) from Names;
MAX(AGE)
----------
23

 min():
SQL> select min(age) from Names;
MIN(AGE)
----------
20

 sum():
SQL> select sum(age) from Names;
SUM(AGE)
----------
86

 avg():
SQL> select avg(age) from Names;
AVG(AGE)
----------
21.5

 ceil():
SQL> select ceil(4.4) from dual;
CEIL(4.4)
----------
5

 floor():
SQL> select ceil(4.4) from dual;
CEIL(4.4)
----------
5

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A61A4


Exp No: Page No:
Date:

Date functions:

 sysdate():
To view the system date.

Query:
SQL> select sysdate from dual;
SYSDATE
---------
10-FEB-24

 last_day():
To view the last day from the month.

Query:
SQL> select last_day(sysdate) from dual;
LAST_DAY(
---------
29-FEB-24

 add_months():
To add the months from the current month.

Query:
SQL> select to_char(add_months(sysdate,2))from dual;
TO_CHAR(ADD_MONTHS
------------------
10-APR-24

 next_day():
To get next coming from the current date.

Query:
SQL> select to_char(next_day(sysdate,'sat')) from dual;

TO_CHAR(NEXT_DAY(S
------------------
17-FEB-24

ADITYA ENGINEERING COLLEGE(A) Roll No: 22A91A61A4

You might also like