0% found this document useful (0 votes)
15 views73 pages

Record DBMS

This document is a record notebook for the Database Management System Lab for a student named Induja D, detailing various SQL commands and experiments conducted during the 2024-2025 academic year. It includes sections on DDL, DML, DCL, and TCL commands, along with examples and outputs for each command type. The document serves as a practical record for the student's lab work and includes a bonafide certificate from the department.

Uploaded by

madhumithaaids
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)
15 views73 pages

Record DBMS

This document is a record notebook for the Database Management System Lab for a student named Induja D, detailing various SQL commands and experiments conducted during the 2024-2025 academic year. It includes sections on DDL, DML, DCL, and TCL commands, along with examples and outputs for each command type. The document serves as a practical record for the student's lab work and includes a bonafide certificate from the department.

Uploaded by

madhumithaaids
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/ 73

FORM NO.

- F/ TL / 021
Rev.00 Date 20.03.2020

RECORD NOTEBOOK

DATABASE MANAGEMENT SYSTEM LAB –(EBCS22L02)

DEPARTMENT

OF

COMPUTER SCIENCE AND ENGINEERING

NAME : INDUJA.D

REGISTER NO : 231191101061

COURSE : B.TECH CSE-DS&AI

YEAR/SEM/SEC : II/III/AA

2024-2025 (ODD SEMESTER)


FORM NO. - F/ TL / 021
Rev.00 Date 20.03.2020

BONAFIDE CERTIFICATE

REGISTER NO: 231191101061

NAME OF LAB: DATABASE MANAGEMENT SYSTEM LAB (EBCE22L02)


DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING

Certified that, this Record note book is a bonafide record of work


done By INDUJA D of II Year B.Tech CSE DS&AI, Sec-‘AA’ in the
DATABASE MANAGEMENT SYSTEM LAB - (EBCE22L02) during the
year 2024-2025.

Signature of Lab-in-Charge Signature of Head of Dept

Submitted for the Practical Examination held on ---------------------------------

Internal Examiner External Examiner


INDEX

PAGE STAFF SIGNATURE


S.NO. DATE NAME OF THE EXPERIMENT No.

EXECUTION OF DDL COMMANDS


1 24/9/2024

EXECUTION OF DML COMMANDS


2 24/9/2024

3 EXECUTION OF DCL COMMANDS


1/10/2024

EXECUTION OF TCL COMMANDS


4 1/10/2024

5 1/10/2024 EXECUTION OF INSERT COMMANDS

NESTED QUERIES
6(a) 8/10/2024
AGGREGATION OPERATIONS
6(b)
8/10/2024

6(c) 22/10/2024 GROUPING AND ORDERING

COMMANDS

7 22/10/2024 SELECT,FROM AND WHERE CLAUSE


(SQLITE3)

8 29/10/2024 SET OPERATIONS

9 5/11/2024 STRING OPERATIONS

10 5/11/2024
EXECUTION JOIN OPERATIONS

11 12/11/2024 CONTROL STATEMENT(FOR LOOP)


(PL/SQL)
12/11/2024 CONTROL STATEMENT(WHILE
12
LOOP)

19/11/2024 CONTROL STATEMENT(FOR


13
REVERSE LOOP)

19/11/2024 CONTROL STATEMENT(LOOP END


14
LOOP)

15 24/11/2024 IMPLEMENTATION OF SUM OF EVEN


NUMBERS

16 24/11/2024 IMPLEMENATION OF SUM OF ODD

NUMBERS

10/12/2024 IMPLEMENTATION OF SERIES


17
GENERATION

18 10/12/2024 IMPLEMENTATION OF SUB PROGRAM

19 17/12/2024 IMPLEMENTION OF CURSOR USING


PL/SQL

17/12/2024 IMPLEMENTATION OF CONTROL


20
STATEMENT (IF-ELSE END IF)
EX.NO:1 EXECUTION OF DDL COMMANDS DATE: 24/09/2024

AIM:

DDL Commands:
There are five commands in DATA DEFINITION LANGUAGE. They Are as follows:
1. Create.
2. Alter.
3. Drop.
4. Truncate.
5. Rename.

1. CREATE

This DDL command is used to create an object in the database.


SYNTAX:
Create table <table_name>(var_name datatype,var_name1 datatype);

EXAMPLE: Create Students table with the following attributes: StudentID, Name,
DateOfBirth, Gender and Phone.

CREATE TABLE Students (StudentID INT, Name VARCHAR(50),DateOfBirth


DATE, Gender CHAR(1), Phone VARCHAR(15));

INDUJA D 1 231191101061
OUTPUT:

2. ALTER:

This alter command is used to change the structure of the database. The alter command is
used along with the following sub-commands
a) ADD

This command is used for adding a new attribute to the database.

SYNTAX:
ALTER TABLE <table_name> ADD (A1D1,A2D2,A3D3,. AnDn);

EXAMPLE: Add an attribute Address onto the table Students.

ALTER TABLE Students ADD Address VARCHAR(200);

INDUJA D 2 231191101061
OUTPUT:

MODIFY: This alter command is used to change the attribute name of the database.

SYNTAX:
ALTER TABLE <table_name> MODIFY (column_namedata_type);

EXAMPLE: Modify the attribute Phone from table Students and make numeric.

ALTER TABLE Students MODIFY (Phone INT);

INDUJA D 3 231191101061
OUTPUT:

DROP:
The drop DDL command is used to delete an object from the database.

SYNTAX:
DROP TABLE <table_name>;

EXAMPLE: Drop the table Employee

DROP TABLE Employee;

INDUJA D 4 231191101061
OUTPUT:

TRUNCATE:
The truncate command is used to remove all the records and attributes from the table
including the space allotted for the record.
SYNTAX:
TRUNCATE table<table_name>;

EXAMPLE: Truncate the table Students.


TRUNCATE table Students;
OUTPUT:

INDUJA D 5 231191101061
RENAME:
The rename command is used to rename an object in the database.
SYNTAX:
RENAME<old table_name> TO <new table_name>;

EXAMPLE: Rename the table Students to Students_details


RENAME Students TO Students_details;
OUTPUT:

RESULT:

INDUJA D 6 231191101061
EX.NO:2 EXECUTION OF DML COMMANDS DATE: 24/9/2024

AIM:

Following are the four main DML commands in SQL:


1. INSERT Command
2. SELECT Command
3. UPDATE Command
4. DELETE Command

INSERT:
This DML command is used to insert records into a table relation.
SYNTAX:
INSERT INTO <table_name> VALUES (‘A11’5,‘A2’,. ....); OR

INSERT INTO table_name (column_name , column_name , column_name ...)


VALUES (value, value, value …)

EXAMPLE:
Insert into Students_details values (‘211011011101’, ‘Payal’, ‘2000-08-
24’,’F’,’9567859624’, ‘A-102, Garden Street’,96)

INSERT INTO Students_details (StudentID, Name, DateOfBirth, Gender, Phone,


Address, Marks) VALUES (211011011101, 'Payal', '2000-08-08', 'F', '9567859624', 'A-
102, Garden Street', 96);

INDUJA D 7 231191101061
OUTPUT:

SELECT:
The select statement is used to retrieve data from the database.
Select statement can be used to display all the records in the relation table by using [*] for
selecting all the attributes. For displaying the records without duplicity, the DISTINCT
keyword is used.
SYNTAX:

⮚ SELECT * FROM <table_name>;


- to display all the attributes from the table.
⮚ SELECT<A1, A2, A3,...> FROM <table_name>;
-for displaying the records in the particular attributes.

⮚ SELECT DISTINCT <A1,A2,A3,. ..... >FROM<table_name>;


- for displaying the records without duplicity.
-

⮚ SELECT ALL<A1,A2,A3, ..... > FROM<table_name>;


- for displaying the records with duplicity in an attribute.

INDUJA D 8 231191101061
EXAMPLE:

⮚ Display all the records present in the Students_details table


SELECT * FROM Students_details;
OUTPUT:

EXAMPLE:

⮚ Display the attributes StudentID and Name from the Students_details table.
SELECT StudentID, Name FROM Students_details;
OUTPUT:

EXAMPLE:
Display the records in the attribute Name without duplicates from the Students_details
table. SELECT DISTINCT Name FROM Students_details;

INDUJA D 9 231191101061
OUTPUT:

UPDATE
UPDATE statement is used to modify existing rows.
1. To update all rows data in a table at a time.
2. To update a specific row data in a table by using the “where” condition.
SYNTAX:
UPDATE table_name SET column=value
Eg: update students_details set name='Siva’;
update the value of a single field
OUTPUT:

INDUJA D 10 231191101061
DELETE :To remove single or multiple existing records from the database tables
Eg: delete students_details;
To delete all of the rows in the table.
Eg: Deleting the row that contains particular data
DELETE FROM table_name WHERE condition
OUTPUT:

RESULT :

INDUJA D 11 231191101061
EX.NO:3 EXECUTION OF DCL COMMANDS DATE: 1/10/2024

AIM:

The two types of DCL commands are as follows:


o GRANT : Allows the administrator to provide particular privileges or permissions
over a database object, such as a table, view, or procedure. It can provide user access
to perform certain database or component operations.
o REVOKE : Enables the database administrator to remove the previously provided
privileges or permissions from a user over a database or database object, such as a
table, view, or procedure.

CREATE USER :
Syntax : CREATE USER user_account IDENTIFIED BY password;

INDUJA D 12 231191101061
GRANT :
Syntax :GRANT privileges_names ON object TO user;

Explanation:
● privileges_name: These are the access rights or privileges granted to the user.
● object: It is the name of the database object to which permissions are being
granted. In the case of granting privileges on a table, this would be the table
name.
● user: It is the name of the user to whom the privileges would be granted.

REVOKE :
This statement is used to revoke some or all of the privileges which have been granted to a
user in the past.
Syntax:
REVOKE privileges ON object FROM user;
Parameters Used:
● object: It is the name of the database object from which permissions are being
revoked. In the case of revoking privileges from a table, this would be the table name.
● user: It is the name of the user from whom the privileges are being revoked.

INDUJA D 13 231191101061
RESULT :

INDUJA D 14 231191101061
EX.NO:4 EXECUTION OF TCL COMMANDS DATE: 1/10/2024

AIM:

COMMIT : To save all the transaction-related changes permanently to the disk.


Syntax:
COMMIT;

SAVEPOINT :
Syntax:
SAVEPOINT savepoint_name;

ROLLBACK :
roll back the transaction using the ROLLBACK command to the savepoint INS, which we
have created before executing the DELETE query.
Syntax:
ROLLBACK TO savepoint_name;
Example : create a table and insert values set a savepoint called Insertion

BEGIN / START TRANSACTION command is used to start the transaction.


START TRANSACTION;
SAVEPOINT Insertion;
Execute update command and select then set another savepoint called Updation.
Suddenly, our requirement changed, and we realized that we had updated a record that was
not supposed to be. In such a scenario, we need to roll back our transaction to the savepoint,
which was created prior to the execution of the UPDATE command.
ROLLBACK TO Insertion;

INDUJA D 15 231191101061
OUTPUT :

RESULT :

INDUJA D 16 231191101061
EX.NO:5 EXECUTION OF INSERT COMMANDS DATE: 1/10/2024

AIM:

Syntax:
insert into <table_name> values(‘A11’5,‘A2’, ....... );
Example :
insert into students_details values(101,'sam','12-10-1999','m',12323231,'chennai')

INDUJA D 17 231191101061
Unique Constraints:
This constraint ensures that no two rows have the same values in the specified column.
eg: create table employee_details (ecode numeric NOT NULL UNIQUE, ename char(20)
NOT NULL, gender char (1) NOT NULL, grade char (2), gross decimal);

Output: Table created.

Primary Constraints:
This constraint declares a column as the PRIMARY KEY of the table. This constraint is
similar to UNIQUE constraint except that only one column (or one group of columns) can be
applied in this constraint. The PRIMARY KEY cannot allow NULL values.

eg: create table employee_details (ecode numeric NOT NULL PRIMARY KEY, ename
char(20) NOT NULL, sex char (1) NOT NULL, grade char (2), grossdecimal);

Output: Table created with ecode as the PRIMARY KEY.

INDUJA D 18 231191101061
ARITHMETIC EXPRESSION:
Arithmetic operations like addition, subtraction, multiplication, division can be performed on
the records in an attribute. It can also be performed on constants of tuples. Select clause may
also contain arithmetic involving +, *, -, /.

EXAMPLE:  Find the loan_no, branch_name and amount*100 in the loan_details relation
table.
select loan_no, branch_name, amount*100 from loan_details1173;

OUTPUT:

WHERE clause: The where clause is used to conditionally select data from a table; where
clause can be added to the select statement.
EXAMPLE: Display the loan_no having a loan at the Perryridge branch and having amount
greater than Rs.1200 from loan_details relation.
select loan_no from loan_details where branch_name = ‘Perryridge’ and amount>1200;

INDUJA D 19 231191101061
OUTPUT:

BETWEEN COMPARISON OPERATOR: The between comparison operator is used to


set a condition for the tuples having the values between the range of the given high and the
low value.
EXAMPLE: Find all the loan_no from the loan_details relation table where the amount is
between Rs.1500 and Rs.2000.
select loan_no from loan_details1173 where amount between 1500 and 19 2000;
OUTPUT:

INDUJA D 20 231191101061
EXAMPLE: Find all the customers who have the loan from the bank. Also find their loan_no
and loan amount.
select customer_name ,loan_no, amount from loan_details, borrower_details where
loan_details.loan_no = borrower_details.loan_no;

OUTPUT:

RESULT :

INDUJA D 21 231191101061
Ex:6 (a) NESTED QUERIES Date: 8/10/2024

Aim:

Syntax:
Select column1,column2,..from table1 where column1 IN (select column1 from table2
where codition)
Operators Used :
IN, NOT IN, ALL, ANY , EXIST, NOT EXIST

IN Connective :
Syntax:. Select attribute_name from relation_1 where IN (select from );

NOT IN Connective :
Syntax: select from where condition NOT IN (select from relation_02);

Example: ➢ Find all the customers who have both a loan and an account at the bank.

select distinct customer_name from borrower_details where


customer_name IN (select customer_name from depositor_details);

CREATE TABLE borrower_details(borrower_id int,custmoer_name varchar(10))


insert into borrower_details values(1,'Thomas')
insert into borrower_details values(2,'sam')
select * from borrower_details

CREATE TABLE depositor_details(depositor_id int,custmoer_name varchar(10))


insert into depositor_details values(1,'Thomas')
insert into depositor_details values(2,'Rasak')
select distinct custmoer_name from borrower_details where custmoer_name IN (select
custmoer_name from depositor_details);

INDUJA D 22 231191101061
OUTPUT :

Example: ➢ Find the customer who have loan at the bank but do not have an account
at the bank.

Select distinct customer_name from borrower_details where


customers_name NOT IN (select coustomer_name form depositer_details);

Example: ➢ Find all customers who have loan at the bank and names are neither Smith
nor Jones.

INDUJA D 23 231191101061
select distinct customer_name from borrower_details where customer_name NOT IN
(‘Thomas’,’sam’);
OUTPUT:

EXIST:
Example:

CREATE AN EMPLOYEE TABLE WITH EMP_ID,EMP_NAME,DEPT_ID


INSERT VALUES INTO THE EMPLOYEE TABLE

CREATESALESTABLEWITHSALAES_ID,EMP_ID,SALE_AMT
INSERT VALUES INTO THE SALES TABLE.

1) Find the names of all employees in the Sales department.

SELECT emp_name
FROM employees

WHERE EXISTS (SELECT emp_id


FROM sales
WHERE employees.emp_id = sales.emp_id);

INDUJA D 24 231191101061
OUTPUT :

ALL:
Example:
Find the names of all employees who have made sales greater than $1000.
SELECT emp_name
FROM employees
WHERE emp_id = ALL (SELECT emp_id
FROM sales
WHERE sale_amt > 1000);

INDUJA D 25 231191101061
OUTPUT:

RESULT:

INDUJA D 26 231191101061
Ex:6 (b) AGGREGATION OPERATORS Date: 8/10/2024

Aim:

Aggregate functions are often used with the GROUP BY clause of the SELECT statement.
The GROUP BY clause splits the result-set into groups of values and the aggregate function
can be used to return a single value for each group.
The most commonly used SQL aggregate functions are:
● MIN() - returns the smallest value within the selected column
● MAX() - returns the largest value within the selected column
● COUNT() - returns the number of rows in a set
● SUM() - returns the total sum of a numerical column
● AVG() - returns the average value of a numerical column
MIN() : select min(studentid) from students_details;
OUTPUT:

INDUJA D 27 231191101061
MAX(): SELECT MAX(MARKS) FROM student_details;
OUTPUT:

SELECT MAX(MARKS) FROM student_details WHERE SUBJECT=’MATHS’;

OUTPUT:

INDUJA D 28 231191101061
ALIAS NAME: SELECT MIN(MARKS) as Minimum_marks FROM student_details;

OUTPUT:

COUNT() : function returns the number of rows that matches a specified criterion.
SELECT COUNT(*) FROM STUDENT_DETAILS;
OUTPUT:

SUM() : function returns the total sum of a numeric column.

INDUJA D 29 231191101061
SELECT SUM(MARKS) FROM STUDENT_DETAILS;
OUTPUT:

SELECT STUDENT_ID, SUM(MARKS) AS TOTAL FROM STUDENT_Details


GROUP BY STUDENT_ID;
OUTPUT:

INDUJA D 30 231191101061
AVG() : function returns the average value of a numeric column.
SELECT AVG(MARKS) FROM STUDENT_Details; OUTPUT
:

SELECT AVG(column_name) FROM table_name WHERE condition;


OUTPUT :

RESULT:

INDUJA D 31 231191101061
Ex: 6 (c) GROUPING & ORDERING COMMAND Date: 22/10/2024

Aim:

Description:
Group By: Used to group rows that have the same values into summary rows, typically
used with aggregate functions like SUM, COUNT, AVG, etc…
GROUP BY Syntax :
SELECT column_name(s) FROM table_name WHERE condition
GROUP BY column_name(s) ORDER BY column_name(s);

Order By: Sort the result set either in ascending or descending order.

Example: ➢ Grouping loan details by at the branch_name.

create table account_details(acc_id int,balance int,branchname varchar(20))


insert into account_details values(1001,10000,'Maduravoyal')
insert into account_details values(1002,20000,'Mogappair')
Select branchname,avg(balance) as avg_balance from account_details group by
branchname;
OUTPUT:

INDUJA D 32 231191101061
Example: ➢ lists the number of acc_id in each branch, sorted high to low

SELECT COUNT(acc_id), branchname FROM account_details


GROUP BY branchname ORDER BY COUNT(acc_id) DESC;
OUTPUT:

RESULT:

INDUJA D 33 231191101061
EX.NO:7 SELECT,FROM AND WHERE CLAUSE (sqlite3) DATE: 29/10/2024

AIM:

ALGORITHM:

Program :
import sqlite3

# Connecting to sqlite
# connection object
connection_obj = sqlite3.connect('student1.db')

# cursor object

INDUJA D 34 231191101061
cursor_obj = connection_obj.cursor()

connection_obj.execute("""CREATE TABLE student_sqlite1(


Email varchar(255),
Name varchar(50),
Score int
);""")

connection_obj.execute(
"""INSERT INTO student_sqlite1 (Email,Name,Score) VALUES
("Sam.com","CSE",50)""")
connection_obj.execute(
"""INSERT INTO student_sqlite1 (Email,Name,Score) VALUES
("Thomas.com","AI",55)""")
connection_obj.execute(
"""INSERT INTO student_sqlite1 (Email,Name,Score) VALUES
("Vicky.com","AI",60)""")

INDUJA D 35 231191101061
cursor_obj = connection_obj.cursor()

# to select all column we will use


statement = '''SELECT * FROM student_sqlite1'''

cursor_obj.execute(statement)
print("All the data")
output = cursor_obj.fetchall()
for row in output:
print(row)

connection_obj.commit()

# Close the connection


connection_obj.close()
OUTPUT :

INDUJA D 36 231191101061
RESULT:

INDUJA D 37 231191101061
EX.NO: 8 SET OPERATION DATE: 29/10/24

Aim:

Description: SET operators are special type of operators which are used to combine the
result of two queries.
Operators covered under SET operators are:

1. UNION
2. UNION ALL
3. INTERSECT
4. MINUS

1. Union :

SELECT *FROM customers_details UNION SELECT *FROM employee_details1;

OUTPUT:

INDUJA D 38 231191101061
2. UNION ALL:

● This operator combines all the records from both the queries.
● Duplicate rows will be not be eliminated from the results obtained after
performing the UNION ALL operation.

SELECT *FROM customers_details UNION ALL SELECT *FROM


employee_details1;
OUTPUT:

3. INTERSECT :
○ It is used to combine two SELECT statements, but it only returns the records
which are common from both SELECT statements.

OUTPUT :

INDUJA D 39 231191101061
4. MINUS

○ It displays the rows which are present in the first query but absent in the second
query with no duplicates.

SELECT *FROM customers_details MINUS SELECT *FROM employee_details1;

OUTPUT:

RESULT:

INDUJA D 40 231191101061
EX.NO:9 STRING OPERATIONS DATE: 5/11/24

Aim:

Concatenation :

Operation: Combine two or more strings.

Syntax: Use the || operator.

SELECT 'Hello' || ' ' || 'World' AS concatenated_string FROM dual;

Output:

Substring :

● Operation: Extract a portion of a string.


● Function: SUBSTR(string, start_position, length)

SELECT SUBSTR('Oracle Database', 8, 8) AS substring_result FROM dual;

INDUJA D 41 231191101061
Output:

String Length :

● Operation: Find the length of a string.


● Function: LENGTH(string)

● SELECT LENGTH('Oracle') AS string_length FROM dual;Output:

INDUJA D 42 231191101061
String Replacement

● Operation: Replace part of a string.


● Function: REPLACE(string, search_string, replace_string)

SELECT REPLACE('Oracle Database', 'Database', 'Cloud') AS replaced_string


FROM dual;

Output:

Changing Case :

● Operation: Convert to upper or lower case.


● Functions: UPPER(string) and LOWER(string)

SELECT UPPER('oracle') AS upper_case, LOWER('ORACLE') AS lower_case FROM


dual;

INDUJA D 43 231191101061
Output:

Trimming
Spaces

● Operation: Remove spaces from the start, end, or both ends of a string.
● Functions:
○ TRIM() – Removes specified characters or spaces from both ends.
○ LTRIM() – Removes characters from the left.
○ RTRIM() – Removes characters from the right.

○ SELECT TRIM(' Oracle ') AS trimmed_string FROM dual;

Output:

INDUJA D 44 231191101061
Padding

● Operation: Pad a string to a specific length with characters.


● Functions: LPAD(string, length, pad_string) and RPAD(string, length,
pad_string)

SELECT LPAD('Oracle', 10, '*') AS left_padded, RPAD('Oracle', 10, '*') AS


right_padded FROM dual;

Output:

Finding Position :

● Operation: Locate the position of a substring.


● Function: INSTR(string, substring)

SELECT INSTR('Oracle Database', 'Database') AS position FROM dual;

INDUJA D 45 231191101061
Output:

Reversing a String:

● Operation: Reverse the characters in a string.


● Function: REVERSE(string)

SELECT REVERSE('Oracle') AS reversed_string FROM dual;

Output:

RESULT :

INDUJA D 46 231191101061
EX.NO:10 EXECUTION OF JOIN OPERATION DATE: 5/11/24

Aim:

Syntax :
SELECT column_name(s) FROM table1 INNER JOIN table2 ON
table1.column_name = table2.column_name;

Perform an inner join between the employee and sales relation based on the emp_id.

SELECT e.emp_id,e.emp_name FROM employee e INNER JOIN sales ON e.emp_id =


sales.emp_id;

OUTPUT:

INDUJA D 47 231191101061
LEFT OUTER JOIN:
The LEFT JOIN keyword returns all records from the left table (table1), and
the matching records from the right table (table2).

Syntax :
SELECT column_name(s) FROM table1 LEFT JOIN table2
ON table1.column_name = table2.column_name;

Example :
SELECT employee.emp_name, sales.sale_id FROM
employee
LEFT JOIN sales ON employee.emp_id = sales.emp_id ORDER
BY employee.emp_name;

OUTPUT :

INDUJA D 48 231191101061
RIGHT OUTER JOIN:
The RIGHT JOIN keyword returns all records from the right table (table2), and the
matching records from the left table (table1).

Syntax:
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
Example :
SELECT sales.sale_id,employee.emp_name FROM sales RIGHT
JOIN employee ON sales.emp_id = employee.emp_id ORDER BY
sales.sale_id;

OUTPUT :

RESULT:

INDUJA D 49 231191101061
EX.NO:11 CONTOL SATEMENT (For loop) DATE: 12/11/2024

Aim:

Algorithm:

Program :
DECLARE
i NUMBER := 1;
BEGIN
LOOP
EXIT WHEN i>10;
DBMS_OUTPUT.PUT_LINE(i); i
:= i+1;
END LOOP;
END;

OUTPUT:

INDUJA D 50 231191101061
RESULT:

INDUJA D 51 231191101061
EX.NO:12 CONTROL STATEMENT (While loop) DATE: 12/11/2024

Aim:

Algorithm:

Program :
DECLARE
i INTEGER := 1;
BEGIN
WHILE i <= 10 LOOP
DBMS_OUTPUT.PUT_LINE(i);
i := i+1;
END LOOP;
END;

INDUJA D 52 231191101061
OUTPUT:

RESULT:

INDUJA D 53 231191101061
EX.NO:13 CONTROL STATEMENT (for reverse loop) DATE: 19/11/2024

Aim:

Algorithm:

Program :
DECLARE
VAR1 NUMBER;
BEGIN
VAR1:=1;
FOR VAR2 IN REVERSE 1..10
LOOP
DBMS_OUTPUT.PUT_LINE (VAR1*VAR2);
END LOOP;
END;

INDUJA D 54 231191101061
OUTPUT :

RESULT:

INDUJA D 55 231191101061
EX.NO:14 CONTROL STATEMENT (loop end loop) DATE: 19/11/2024

Aim:

Algorithm:

Program :
Declare I numeric (3);
Begin
I:=1;
Loop dbms_output.put_line(i);
I:=i+1;
If(i=10) then exit;
End if;
End loop;
End;

INDUJA D 56 231191101061
OUTPUT :

RESULT:

INDUJA D 57 231191101061
EX.NO:15 IMPLEMENTATION OF SUM OF EVEN NUMBER DATE: 26/11/2024

Aim:

Algorithm:

Program :
DECLARE
-- Declare variable num
num NUMBER(3) :=2 ;
sum1 NUMBER(4) := 0;
BEGIN
WHILE num <= 20 LOOP
-- Display even number
dbms_output.Put_line(num);
-- Sum of even numbers
sum1 := sum1 + num;
-- Next even number
num := num + 2;
-- End loop
END LOOP;
-- Display even number
dbms_output.Put_line('Sum of even numbers is ' || sum1);
END;

INDUJA D 58 231191101061
OUTPUT :

RESULT:

INDUJA D 59 231191101061
EX.NO:16 IMPLEMENTATION OF SUM OF ODD NUMBERS DATE: 26/11/24

Aim:

Algorithm:

PROGRAM:
DECLARE
-- Declare variable num
num NUMBER(3) :=1 ;
sum1 NUMBER(4) := 0;
BEGIN
WHILE num <= 20 LOOP
-- Display even number
dbms_output.Put_line(num);
-- Sum of even numbers
sum1 := sum1 + num;
-- Next even number
num := num + 2;
-- End loop
END LOOP;
-- Display even number
dbms_output.Put_line('Sum of oddnumbers is ' || sum1);
END;

INDUJA D 60 231191101061
OUTPUT:

RESULT :

INDUJA D 61 231191101061
EX.NO:17 IMPLEMENT OF SERIES GENERATION DATE: 10/12/2024

Aim:

Algorithm:

Program:

DECLARE
n NUMBER := 10; -- Number of terms in the Fibonacci series
a NUMBER := 0;
b NUMBER := 1;
c NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('Fibonacci Series:');
DBMS_OUTPUT.PUT_LINE(a);
DBMS_OUTPUT.PUT_LINE(b);

FOR i IN 3..n LOOP

INDUJA D 62 231191101061
c := a + b;
DBMS_OUTPUT.PUT_LINE(c);
a := b;
b := c;
END LOOP;
END;

OUTPUT:

RESULT:

INDUJA D 63 231191101061
EX.NO:18 IMPLEMENTATION OF SUB PROGRAM DATE: 10/12/2024

Aim:

Algorithm:

Program :

DECLARE
i number;
j number;
k number;
PROCEDURE findAdd(num1 IN number, num2 IN number, sum OUT number) IS
BEGIN
sum := num1 + num2;
END;
BEGIN
i:= 5;
j:= 5;
findAdd(i, j, k);
dbms_output.put_line(' The sum is : ' || k);
END;

INDUJA D 64 231191101061
OUUTPUT :

RESULT :

INDUJA D 65 231191101061
EX.NO:19 IMPLEMENTATION OF CURSOR USING PL/SQL DATE: 17/12/2024

Aim:

Algorithm:

Program :
DECLARE
c_id customers.id%type;
c_name customers.name%type;
c_addr customers.address%type;
CURSOR c_customers is
SELECT id, name, address FROM customers;
BEGIN
OPEN c_customers;
LOOP
FETCH c_customers into c_id, c_name, c_addr;
EXIT WHEN c_customers%notfound;
dbms_output.put_line(c_id || ' ' || c_name || ' ' || c_addr);
END LOOP;

INDUJA D 66 231191101061
CLOSE c_customers;
END;

OUTPUT:

RESULT :

INDUJA D 67 231191101061
EX.NO:20 IMPLEMENTATION OF CONTROL DATE: 17/12/2024
STATEMENT(if-elsif-end if)

Aim:

Algorithm:

Program :

DECLARE
mark NUMBER:=55;
BEGIN
dbms_output.put_line('program started');

IF(mark>=70) THEN
dbms_output.put_line('Grade A');
ELSIF(mark>=40 AND mark < 70) THEN
dbms_output.put_line('Grade B');
ELSIF(mark>=35 AND mark<40) THEN

INDUJA D 68 231191101061
dbms_output.put_line('Grade C');
end if;
dbms_output.put_line('Program completed');
end;

OUTPUT:

RESULT :

INDUJA D 69 231191101061

You might also like