Oracle RDBMS Lab Manual Dec 2022 (26!10!2022)
Oracle RDBMS Lab Manual Dec 2022 (26!10!2022)
III B.C.A
RECORD NOTEBOOK
2022-2023
…………………………………………………
Semester: V
…………………….. ……………………..
Staff-in-charge Head of the department
Date:………………….
Submitted for the practical examination held in November 2022 at Scott Christian
College (Autonomous), Nagercoil .
Examiner1:
Examiner2:
INDEX
S.NO CONTENT PG. NO SIGN
1
TABLE CREATION
2
FIBONACCI NUMBERS
3
ARMSTRONG NUMBER
4
SUM OF DIGITS
6
MULTIPLICATION TABLE
7
REVERSING A NUMBER
8
PALINDROME
9
SQL OPERATIONS
11
VIEW CREATION
𝐄𝐱.𝐍𝐨 :
TABLE CREATION
𝐃𝐚𝐭𝐞 :
AIM :
PROCEDURE:
1. Open SQL*plus
2. Enter the user name and password to begin and connect to oracle server.
3. In the SQL Prompt type the query to create tables with the following columns and
constraints.
Book Master
CODING :
AIM :
To write a PL/SQL code to find the fibonacci numbers.
PROCEDURE :
8. Open SQL*plus
9. Enter the username and password to login and connect to oracle server.
11. In SQL number of typed followed by filename. SQL and type the code in notepad window.
13. Get the prompt number term as input to initialize y1=0; y2=1.
15. Repeat it until we get the required number of terms and close the loop.
16. Display the result to execute the PL/SQL program using the command >@ filename.
CODING:
Declare
i number;
n number;
f1 number;
f2 number;
f3 number;
begin
n:='&n';
f1:=0;
f2:=1;
dbms_output.put_line('The fibonacci numbers are;');
dbms_output.put_line(f1);
dbms_output.put_line(f2);
for i in 3..n loop
f3:=f1+f2;
dbms_output.put_line(f3)
; f1:=f2;
f2:=f3;
end loop; end;
OUTPUT :
RESULT :
PL/SQL program is executed successfully.
𝐄𝐱.𝐍𝐨 :
ARMSTRONG NUMBER
𝐃𝐚𝐭𝐞 :
AIM :
To write a SQL program to create Armstrong number.
PROCEDURE :
1. open SQL*plus.
2. Enter the username and password to login and connect to oracle server. ASQ >is display.
iii. In notepad, declare the required variable begin the loop and calculate the Armstrong
number
3. End the loop.
4. Display the output.
5. End the PL/SQL block.
CODING:
Declare
n number(3);
s number(3):=0;
t number(3);
begin
n:=&n;
t:=n;
end loop;
if(s=n)then
dbms_output.put_line('thegivennumber '||n|is an armstrong number');
else dbms_output.put_line('the given number '||n||' is not an Armstrong number');
endif;
end;
OUTPUT:
RESULT:
PL/SQL program is executed successfully
𝐄𝐱.𝐍𝐨 :
𝐏𝐑𝐎𝐆𝐑𝐀𝐌 𝐔𝐒𝐈𝐍𝐆 𝐂𝐔𝐑𝐒𝐎𝐑
𝐃𝐚𝐭𝐞 :
𝐀𝐈𝐌 :
To write a PL/SQL code to find the program using cursor.
𝐏𝐑𝐎𝐂𝐄𝐃𝐔𝐑𝐄 :
1. Open SQL*plus
2. Enter the username and password to login and connect to oracle server. A SQL> is display
4. In SQL number of type ed followed by forename SQL and type code in notepad window
𝐂𝐎𝐃𝐈𝐍𝐆 :
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
SQL>Select*from employee;
EmpnoEmpname Salary
--------------------------------------------------------------------
1 asha 30000
2 ancy 35000
3 rancy 20000
4 alan 25000
5 banu 38000
SQL>Declare
3 Begin
4 For I in cl
5 Loop
6 Dbms_output.put_line(I.ename||’ ‘||I.sal);
7 End loop;
8 End;
9 /
Asha 30000
Ancy35000
Rancy 20000
Alan 25000
Banu 38000
𝐑𝐄𝐒𝐔𝐋𝐓 :
PL/SQL program is executed successfully.
𝐄𝐱.𝐍𝐨 :
AIM:
To write a PL/SQL to find the sum of digits.
PROCEDURE:
1. Open SQL*Plus
2. Type ed(edit) followed any file name SQL
3. Type the required coding in the notepad window
4. Declare the required variable
5. Begin the loop and do the calculation
6. End the loop
7. Display the output
8. End the PL/SQL block
9. Save the file and selected file ->Exit
10. In SQL prompt type SQL->setserver output on to execute
11. In SQL prompt type SQL->@followed by file name, output in displayed.
CODING:
declare
number(10); s
number(10); r
number(10);
begin
n:='&n';
s:=0;
RESULT:
AIM:
To write a PL/SQL code to create the multiplication table
PROCEDURE:
1. Open SQL*Plus
2. Enter the username and password to login and connect to oracle server
3. Type the command set server output on
4. In the notepad declare the required variables .
5. End the loop display the output
6. End the PL/SQL block
CODING:
Declare
i number;
n number;
c number;
begin
n:=&n
end;
OUTPUT:
RESULT :
PL/SQL program is executed successfully.
𝐄𝐱.𝐍𝐨 :
AIM:
To write SQL queries to the concept of the reversing a number.
PROCEDURE:
1. Open SQL *plus
3. In notepad declare the required variable begin the loop and allowed the receiving
number.
CODING:
Declare
num1number(5);
num2number(5);
rev number(5);
begin
num1:=&num1;
rev:=0;
while num1>0 loop
rev:=num2+(rev*10);
num1:=floor(num1/10);
end loop;
𝐃𝐚𝐭𝐞 : PALINDROME
AIM:
To write a PL/SQL code to find the palindrome.
PROCEDURE:
1. Open SQL*Plus
2. Enter the username and password to login and connect to oracle server. A
SQL>is display.
3. Type the command set server output on
4. In the notepad declare the required variable begin the loop and calculate the
palindrome
5. End the loop display the output
6. End the PL/SQL block
CODING:
Declare Strvarchar2(50):=’&String’;
Counter int:=length(str);
BEGIN dbms_Output.Put_line(Counter):
Counter:=Counter-
1; end loop;
AIM:
To create a database and run when changes are made to a table’s data.
PROCEDURE:
1. Open SQL*Plus
2. Enter the username and password to login
3. In the SQL Prompt type the query to create tables
4. Insert values into the tables
5. List all the records from the tables
6. Update the tables
7. End the loop display the output
8. End the PL/SQL block
CODING:
Select*from employe1;
beforeupdate on employe1
begin
dbms_Output.Put_line(:Old.empname);
dbms_Output.Put_line(:new.empname);
end;
AIM:
To prepare various operations of SQL.
PROCEDURE:
CODING:
DESCRIBE EMPLOYEE;
SQL PERATIONS:
1) BETWEEN,AND:
SELECT FNAME,SALARYF ROME MPLOYEE WHERE SALARY BETWEEN 20000 AND 30000;
2) NOT:
SELECT FNAME FROM EMPLOYEE WHERE DNO NOT IN <1,4,5>;
3)IN:
SELECT FNAME FROM EMPLOYEE WHERE DNO IN <1,4,5>;
4)RENAME:
RENAME EMPLOYEE TO EMPLOYEES;
5)DELETE:
DELETE FROM EMPLOYEES WHERE SSN=123456789;
OUTPUT:
.
Result:
AIM:
To create a sample table and create sequences and synonym in the table
Procedure:
Code:
SQL>Create tableA1(Snonumber(5), Regno number(6), Name
varchar2(20));
Table created
SQL>Describe A1;
Name Null? Type
------------------------------------------------------------------------
SnoNumber(5)
Regno Number(5)
Name varchar2(20)
SQL>Select*fromA1;
SQL>Select*from A1;
SQL>Select*fromA1;
Sno Regno Name
------------------------------------------------------------------------------------
1 200501 Alan
2 200502 Annie
3 200503 Banu
4 200504 Asha
5 200505 Anu
6 200506 Roshini
7 200507 Rancy
8 200508 Ancy
Output :
AIM:
To create view to store employee details and department details.
Procedure:
CODE:
SQL> CREATE TABLE DEPARTMENT(DEPTID NUMBER(2) PRIMARY KEY,
DEPTNAME VARCHAR2(25), NOOFEMP NUMBER(20), LOC
VARCHAR2(20), PHONENO NUMBER(10));
TABLE CREATED.
SQL>SELECT*FROM VW2;
DEPTID DEPTNAME EMPID ENAME DESIG
----------------------------------------------------------------------------------------------------
3 ACCOUNTING 100 ASHA CLERK
1SALES 101 ANCY OFFICE STAFF
3ACCOUNTING102 BANU MANAGER
4MANUFACTURING 103 ANNIE ENGINEER
5PACKING 104 RANCY ASSISTANT
2MARKETING 105ALAN AREA MANAGER
7 ROWS SELECTED.
Result: