DBMS PDF
DBMS PDF
CERTIFICATE
IN THE YEAR………………….
STAFF IN-CHARGE
SUBMITTED FOR
PRACTICAL EXAMINATION
EXTERNAL EXAMINER
1.
2.
INDEX
name,reg_no,mark_1,mark_2,mark_3.
Query 1:
Table created.
Query 2:.
NAME VARCHAR2(20)
REG_NO NUMBER(5)
MARK_1 NUMBER(3)
MARK_2 NUMBER(3)
MARK_3 NUMBER(3)
Query 3:
Table altered.
1
SQL> desc student_Marklist;
NAME VARCHAR2(20)
REG_NO NUMBER(5)
MARK_1 NUMBER(3)
MARK_2 NUMBER(3)
MARK_3 NUMBER(3)
TOTAL NUMBER(3)
4. Modify the Not null value to field of reg_no in the student marklist table.
Query 4:
Table altered.
NAME VARCHAR2(20)
MARK_1 NUMBER(3)
MARK_2 NUMBER(3)
MARK_3 NUMBER(3)
TOTAL NUMBER(3)
2
5. Clear the screen.
Query 5:
SQL>cl scr;
Output:
SQL>
Query 6:
Table dropped.
Query 7:
SQL>desc Student_Marklist;
ERROR:
RESULT:
3
EX.NO:2 DML COMMANDS
Query 8:
5 rows inserted.
Query 9:
Poojakumari 2 60 79 80 219
janani 3 45 55 80 180
Dharshini 4 35 12 55 102
Ayesha 5 75 46 50 171
10. Display only the name and reg_no for all the students.
Query 10:
4
OUTPUT:
NAME REG_NO
-------------------- ----------
Abi 1
Poojakumari 2
janani 3
Dharshini 4
Ayesha 5
Query 11:
OUTPUT:
12. Display the name, mark_2 which mark_2 is less than 35.
Query 12:
OUTPUT:
NAME MARK_2
-------------------- ----------
Dharshini 12
5
13. Change the mark_2 of the student to 86 whose mark_2 is 12.
Query 13:
1 row updated.
Poojakumari 2 60 79 80 219
janani 3 45 55 80 180
Dharshini 4 35 86 55 102
Ayesha 5 75 46 50 171
Query 14:
1 row deleted.
Poojakumari 2 60 79 80 219
janani 3 45 55 80 180
Dharshini 4 35 86 55 176
6
15. Delete all the records using Truncate in student marklist table.
Query 15:
Table truncated.
no rows selected.
RESULT:
7
EX.NO:3 AGGREGATE FUNCTION
name,reg_no,mark_1,mark_2,mark_3.
Query 1:
Table created.
Query 2:
1 rows inserted.
…………………
………………….
8
NAME REG_NO MARK_1 MARK_2 MARK_3
Abi 1 98 99 100
Poojakumari 2 60 79 80
janani 3 45 55 80
Dharshini 4 35 12 55
Ayesha 5 75 46 50
Query 3:
Table altered.
NAME VARCHAR2(20)
REG_NO NUMBER(5)
MARK_1 NUMBER(3)
MARK_2 NUMBER(3)
MARK_3 NUMBER(3)
TOTAL NUMBER(3)
AVERAGE NUMBER(3)
9
4. To find the total and average of the student table.
OUTPUT:
Poojakumari 2 60 79 80 219 73
Janani 3 45 55 80 180 60
Dharshini 4 35 12 55 176 59
Ayesha 5 75 46 50 102 34
OUTPUT:
COUNT(REG_NO)
-----------------------
5
OUTPUT:
10
7. Find the minimum average among all the student.
OUTPUT:
OUTPUT
SUM(MARK_3)
-----------------------
365
OUTPUT:
Poojakuma 2 60 79 80 219 73
10. Display the records who’s got the average above 90 percent.
11
OUTPUT:
RESULT:
12
EX.NO:4 SUB-QUERY
Query 1:
Table created.
Query 2:
Query 3:
13
Query 4:
Select*from customer where id in(select id from customer where salary > 25000);
OUTPUT:
Query 5:
Table created.
Query 6:
SQL> insert into customer_new select*from customer where id in (select id from customer);
Select*From customer_new;
14
Query 7:
SQL>update customer set salary=salary*0.25 where age in(select age from customer_new where
age >=20);
OUTPUT:
5 rows updated.
Query 8:
select*from customer;
OUTPUT:
Query 9:
SQL>delete from customers where age in(select age from customer_new where age >= 23);
OUTPUT:
2 rows deleted.
Query 10:
select*from customer;
15
OUTPUT:
RESULT:
16
EX.NO:5 ROWTYPE
AIM:
CODING:
declare
employee customer_Abi%rowtype;
begin
employee.id:=&id;
employee.name:='&name';
employee.age:=&age;
employee.address:='&address';
employee.salary:=&salary;
employee.age,employee.address,employee.salary);
dbms_output.put_line('ROW INSERTED');
end;
17
OUTPUT:
RESULT:
18
EX.NO:6 FACTORIAL NUMBER
AIM:
CODING:
declare
n number:=&n;
f number:=1;
i number:=1;
begin
while(i<=n)
loop
f:=f*i;
i:=i+1;
end loop;
end;
19
OUTPUT:
RESULT:
20
EX.NO: 7 FIBONACCI SERIES
AIM:
CODING:
declare
n number:=&n;
a number;
b number;
c number;
i number;
begin
a:=0;
b:=1;
dbms_output.put_line(a);
dbms_output.put_line(b);
for i in 2..n
loop
c:=a+b;
dbms_output.put_line(c);
a:=b;
b:=c;
end loop;
end;/
21
OUTPUT:
RESULT:
22
EX.NO:8 ARMSTRONG NUMBER
AIM:
CODING:
declare
n number(3);
s number(3):=0;
r number(3);
t number(3);
begin
n:=&n;
t:=n;
while(n>0)
loop
s:=s+(r*r*r);
n:=trunc(n/10);
end loop;
if(s=t)then
else
end if;
end;/
23
OUTPUT:
RESULT:
24
EX.NO:9 IMPLICIT CURSOR
AIM:
CODING:
declare
total_rows number(2);
begin
total_rows:=sql% rowcount;
end if;
end;
25
OUTPUT:
RESULT:
26
EX.NO: 10 EXPLICIT CURSOR
AIM:
CODING:
declare
c_id customer.id%type;
c_name customer.name%type;
c_address customer.address%type;
begin
open c_customer;
loop
end loop;
close c_customer;
end;
27
OUTPUT:
RESULT:
28
EX.NO:11 STRING MANIPULATION
AIM:
CODING:
declare
s1 varchar2(15);
s2 varchar2(15);
s3 varchar2(30);
s4 varchar2(30);
s5 varchar2(30);
s6 varchar2(30);
s7 varchar2(30);
s8 varchar2(40);
begin
s1:='&s1';
s2:='&s2';
s3:=upper(s1||''||s2);
dbms_output.put_line('Upper string'||s3);
s4:=lower(s1||' '||s2);
dbms_output.put_line('Lower string'||s4);
s5:=ltrim(s1||s2);
dbms_output.put_line('Ltrim string'||s5);
29
s6:=rtrim(s1||s2);
dbms_output.put_line('Rtrim string'||s6);
s7:=initcap(s1||s2);
dbms_output.put_line('Initcap string'||s7);
s8:=concat(s1,s2);
dbms_output.put_line('Concat string'||s8);
end;
OUTPUT:
RESULT:
30
EX.NO:12 EMPLOYEE DETAILS
AIM:
To write a PL/SQL Program for showing the how many records in employee detail table
using Function creation.
CODING:
total number(2):=0;
begin
return total;
end;
declare
total number(2);
begin
total:=totalemp();
end;
31
OUTPUT:
RESULT:
32
EX.NO:13 GREATER NUMBER
AIM:
CODING:
begin
if a>b then
dbms_output.put_line(a);
else
dbms_output.put_line(b);
end if;
end;
declare
x number;
y number;
begin
x:=&x;
y:=&y;
findmax(x,y);
end;
33
OUTPUT:
RESULT:
34
EX.NO:14 EB BILL PREPARATION
AIM:
CODING:
declare
eno number(10):=&eno;
ename varchar(10):='&ename';
cr number(10):=&cr;
pr number(10):=≺
r number(10);
a number(10);
begin
r:=cr-pr;
dbms_output.put_line('OUTPUT: ');
if(r>=700)then
a:=r*5;
elsif(r>=500)then
a:=r*3;
elsif(r>=300)then
a:=r*2;
35
else
dbms_output.put_line('FREE CURRENT');
end if;
end;
OUTPUT:
RESULT:
36
EX.NO:15 EXCEPTION HANDLING
AIM:
CODING:
declare
c_id customer_Abi.Id%type;
c_name customer_Abi.Name%type;
c_add customer_Abi.Address%type;
begin
c_id:='&id';
exception
dbms_output.put_line('error');
end;
37
OUTPUT:
RESULT:
38