Using Functions

Purpose: Oracle provides numerous built-in functions for various data manipulations.Categories:

  • String Functions:
    • UPPER(): Converts a string to uppercase.
    • LOWER(): Converts a string to lowercase.
    • SUBSTR(): Extracts a substring from a string.
    • LENGTH(): Returns the length of a string.
  • Date Functions:
    • SYSDATE: Returns the current date and time.
    • ADD_MONTHS(): Adds a specified number of months to a date.
    • TRUNC(): Truncates a date to a specified unit (like day).
  • Numeric Functions:
    • ROUND(): Rounds a number to a specified number of decimal places.
    • MOD(): Returns the remainder of a division operation.

Example:

SELECT UPPER(first_name) AS uppercase_name, ROUND(salary, 0) AS rounded_salary
FROM employees;

Explanation: This retrieves the first names in uppercase and the salaries rounded to the nearest whole number.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *