0% found this document useful (0 votes)
6 views3 pages

Week 1 Dbms

The document provides examples of various SQL functions related to character manipulation, date handling, and data type conversion. It includes functions like ASCII, CONCAT, INITCAP, ADD_MONTHS, CURRENT_DATE, and TO_CHAR, demonstrating their usage and expected outputs. Each function is illustrated with a SQL query and its result from a dual table in a database context.

Uploaded by

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

Week 1 Dbms

The document provides examples of various SQL functions related to character manipulation, date handling, and data type conversion. It includes functions like ASCII, CONCAT, INITCAP, ADD_MONTHS, CURRENT_DATE, and TO_CHAR, demonstrating their usage and expected outputs. Each function is illustrated with a SQL query and its result from a dual table in a database context.

Uploaded by

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

CHARACTER FUNCTIONS

1. select ascii('a') from dual;


ASCII('A')
----------
97

2. select chr('100') from dual;


C
-
D

3. select concat('hello','world') from dual;


CONCAT('HE
----------
Helloworld

4. select initcap('database management systems') from dual;


INITCAP('DATABASEMANAGEMENT
---------------------------
Database Management Systems

5. select instr('character','h') from dual;


INSTR('CHARACTER','H')
----------------------
2

6. select length('dual table') from dual;


LENGTH('DUALTABLE')
-------------------
10

7. select lower('Schema and INSTANCE') from dual;


LOWER('SCHEMAANDINS
-------------------
schema and instance

8. select upper('datatype') from dual;


UPPER('D
--------
DATATYPE

9. select rpad('primary',8,'A') from dual;


RPAD('PR
--------
primaryA

10. select lpad('primary',8,'A') from dual;


LPAD('PR
--------
Aprimary

11. select replace('jack and jond','j','bl') from dual;


REPLACE('JACKAN
---------------
black and blond

12. select translate('jack and jond','j','bl') from dual;


TRANSLATE('JA
-------------
back and bond

DATE FUNCTIONS
1. SQL> select add_months(date '2025-09-15',1) from dual;
ADD_MONTH
---------
15-OCT-25

2. SQL> select current_date from dual;


CURRENT_D
---------
21-JUL-25

SQL> select sysdate from dual;

SYSDATE
---------
21-JUL-25

SQL> select current_timestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
21-JUL-25 15.41.16.427000 +05:30

SQL> select extract(day from date '2025-12-02') from dual;

EXTRACT(DAYFROMDATE'2025-12-02')
--------------------------------
2

SQL> select last_day(date '2016-02-01') from dual;

LAST_DAY(
---------
29-FEB-16

SQL> select months_between(date '2024-08-28',date '2031-03-12') from dual;

MONTHS_BETWEEN(DATE'2024-08-28',DATE'2031-03-12')
-------------------------------------------------
-78.483871

SQL> select next_day(date '2012-02-12','thursday') from dual;

NEXT_DAY(
---------
16-FEB-12

SQL> select round(date '2023-12-01','YYYY') from dual;

ROUND(DAT
---------
01-JAN-24

SQL> select trunc(date '2023-12-01','YYYY') from dual;

TRUNC(DAT
---------
01-JAN-23

CONVERSION FUNCTIONS

select to_char (date '2017-01-01') from dual;


TO_CHAR(D
---------
01-JAN-17
select to_date('01 jan 2017') from dual;
TO_DATE('
---------
01-JAN-17

You might also like