Dbms Lab Experiment Week1(Modified)
Dbms Lab Experiment Week1(Modified)
Single row functions can be categorized into four types, single row functions are applied for each
row and produces individual output for each row.
1. Number functions
2. Character functions
3. Date functions
4. Conversion functions
Dual Table: dual is a default table, created at the time of oracle installation.
Regd. No:
Database Management Systems Lab
2 Aditya College of Engineering & Technology
Number functions
ABS (): Absolute is the measure of the magnitude of a value. This function returns absolute value is
always a positive number.
Output: 9
CEIL (): This function returns largest integer greater than or equal to n.
Output: 19
FLOOR (): This function returns the smallest integer equal to or less than n.
Output: 18
SQRT (): This function gives the square root of the given value n.
Output: 24
Output: 2
POWER (): This function gives the value of m raised to the power of n.
Output: 27
ROUND (): This function rounds the number to the given number of digits of precision
Output: 14.53
TRUNC (): This function truncates the decimal portion. This function truncates (deletes) m decimal to
n decimal places.
Output: 10.1099
LEAST (): This function returns least integer from a set of integers.
Output: 1
GREATEST (): This function returns GREATEST integer from a set of integers.
Regd. No:
Database Management Systems Lab
3 Aditya College of Engineering & Technology
CHARACTER FUNCTIONS
INITCAP ( ): This function returns the string with first letter of each word in uppercase.
Output: 23
SUBSTR ( ): This function returns a portion of a string beginning at the character position.
Output: such
INSTR ( ): This function returns Nth occurrence of string2 (first character position) in string1. In
string1 characters index begins from 0. This function starts searching from Mth position.
Output: 4
Regd. No:
Database Management Systems Lab
4 Aditya College of Engineering & Technology
Output: 28
TRANSLATE ( ): This function returns a string after replacing some set of characters into another set.
LPAD ( ): This function returns a string as output after padding string2 to the left side of string1 to n
length.
Output: $$$$$$$$$$$$$$$india
RPAD ( ): This function returns a string as output after padding string2 to the right side of string1 to n
length.
Output: india&&&&&&&&&&&&&&&
LTRIM ( ): This function returns a string as output after trim string2 from left side up to the string1
which is not in set.
Output: xyzabcxyz
RTRIM ( ): This function returns a string as output after trim string2 from right side up to the string1
which is not in set.
Output: abcxyzabc
Regd. No:
Database Management Systems Lab
5 Aditya College of Engineering & Technology
DATE FUNCTIONS
SYSDATE: This function returns current date of system.
Result: 11-JUL-17
ADD_MONTHS (): This function returns date d plus n months, i.e adds n months to the given date d.
Result: 15-AUG-48
Result: 01-AUG-18
MONTHS_BETWEEN (): This function returns difference between given two dates.
Result: 4.06451613
Result: -2.9354839
NEXT_DAY (): This function returns the date of the next weekday from the date specified.
Result: 17-AUG-47
Result: 30-JUL-17
LAST_DAY (): This function returns the date of the last day of the month.
Result: 31-AUG-47
Result: 30-APR-17
Regd. No:
Database Management Systems Lab
6 Aditya College of Engineering & Technology
CONVERSION FUNCTIONS
SQL provides three functions to convert a value from one data type to another
TO_CHAR ():
Result: $30000
TO_DATE ():
Result: 25-JAN-17
Result: 02-JAN-17
TO_NUMBER ():
Result: 1210.72
Regd. No:
Database Management Systems Lab