Lakme Project
Lakme Project
Prepared By
R.Rajayogeswari
17120SEC64L Oracle Lab
Syllabus
1. Write SQL queries to create the following tables and insert rows in it.
Employee (eno, ename, deptno, salary, designation)
Dept (deptno, deptname, location)
Student (rollno, name, course, paper1, paper2, paper3)
2. Write SQL queries to create primary key and foreign key constraints in the above given
tables and perform all types of simple retrieval.
3. Write SQL queries to perform all types of advance retrieval using (i) nested sub queries (ii)
set operators.
6. Write SQL queries to create views and index/indices for the tables Employee, Dept and
Student.
8. Write a PL/SQL program that prints mark sheet of students in a University using cursor.
Aim:
To Write SQL queries to create the following tables and insert rows in it. Employee (eno,
ename, deptno, salary, designation), Dept (deptno, deptname, location), Student (rollno, name,
course, paper1, paper2, paper3).
Procedure:
Step 1: Write the create command for employee table with the datatype (eno numeric(5),ename
SQL Commands:
Table created.
ENO NUMBER(5)
ENAME VARCHAR2(20)
DEPTNO NUMBER(3)
SALARY NUMBER(6)
DESIG VARCHAR2(10)
SQL> create table department(deptno numeric(5),deptname varchar(20),location varchar(10));
Table created.
DEPTNO NUMBER(5)
DEPTNAME VARCHAR2(20)
LOCATION VARCHAR(20)
Table created.
RNO NUMBER(5)
NAME VARCHAR2(20)
PAPER1 NUMBER(3)
PAPER2 NUMBER(3)
PAPER3 NUMBER(3)
1 row inserted
SQL>/
1 row inserted
SQL>/
1 row inserted
SQL>/
1 row inserted
SQL>/
1 row inserted
SQL>/
1 row inserted
SQL>/
SQL>/
20 COMMERCE II FLOOR
SQL>/
SQL>/
100 ANI 50 60 50
101 ABI 50 50 50
102 AKIL 80 60 50
Result:
Aim:
To Write SQL queries to create primary key and foreign key constraints in the above
given tables and perform all types of simple retrieval.
Procedure:
Step 5: Using primary key and foreign key, retrieve the records.
SQL Commands:
Table created
Table created
1 row inserted
SQL>/
ERR:…………
SQL>/
ERR:………………………
1 row inserted
SQL>/
ERR…….
SQL>/
1 row inserted
SQL>/
1 row inserted
SQL>/
ERR………………….
20 COMMERCE II FLOOR
Result:
Aim:
To Write SQL queries to perform all types of advance retrieval using (i) nested sub
queries (ii) set operators.
Procedure:
DNO
------
10
20
30
DNO
------
10
20
30
NO RECORDS FOUND
Result:
Aim:
Procedure:
Step 6: Using Self join operator, join Particular fields from both tables.
Step 7: Using Outer Join Operator, join the tables which satisfy some Constraints.
SQL Commands:
TYPES OF JOIN
CARTESIAN JOIN
SELF JOIN
Result:
Aim:
Procedure:
Step 3: Perform Some Character Operations Using CONCAT, INITCAP, LOWER, UPPER,
LENGTH Operators.
Step 4: Perform Some Arithmetic Operations Using POWER, SQRT, CEIL, FLOOR, ROUND
Operators.
Step 5: Perform some other Operations using AVG, MAX, MIN, COUNT operators.
SQL Commands:
CHARACTER FUNCTIONS
SQL>COMPUTER SCIENCE
SQL>Welcome
SQL>welcome
SQL>WELCOME
ARITHMETIC FUNCTIONS
SQL>8
SQL>25
SQL>25
SQL>05
SQL>25.06
OTHER FUNCTIONS
SQL>25
SQL>9
SQL>2
SQL>6
Result:
Aim:
To Write SQL queries to create views and index/indices for the tables Employee, Dept and
Student.
Procedure:
Step 1: Create three tables in the name of Employee, Dept and Student.
SQL Commands:
VIEW CREATED
VIEW CREATED
DNO DNAME
--------------------------------------------------
10 COMPUTER SCIENCE
20 COMMERCE
30 MATHEMATICS
VIEW CREATED
RNO SNAME
---------------------------------------------------------------
100 ANI
101 ASWIN
102 BANU
103 BOB
104 CAT
INDEX
INDEX CREATED
INDEX CREATED
Result:
Aim:
Procedure:
SQL Commands:
/*PACKAGE*/
Table created.
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
1001 emaan 90 90
1002 maji 80 85
1003 sami 78 90
SQL> create or replace package studpack is
end;
Package created.
begin
commit;
end;
begin
commit;
end;
begin
commit;
end;
end;
Package body created.
1001 emaan 90 90
1002 maji 80 85
1003 sami 78 90
1004 nasi 89 98
1001 emaan 90 90
1002 maji 80 85
1003 sami 78 90
1004 rufi 90 80
SQL> execute studpack.stud_del(1004);
1001 emaan 90 90
1002 maji 80 85
1003 sami 78 90
/*TRIGGER*/
NO NAME M1 M2
102 jesi 99 90
103 rufi 70 60
104 mefi 55 70
105 jas 60 60
begin
if inserting then
dbms_output.put_line('Sucessfully Inserting');
dbms_output.put_line('Sucessfully updating');
dbms_output.put_line('Sucessfully deleted');
end if;
end;
Trigger created.
Sucessfully Inserting
1 row created.
Sucessfully deleted
1 row deleted.
1 row updated.
NO NAME M1 M2
102 jesi 99 90
103 rufi 70 60
104 mefi 55 70
105 jasi 60 60
Result:
Aim:
To Write a PL/SQL program that prints mark sheet of students in a University using cursor.
Procedure:
PL/SQL Commands:
SQL> declare
r stud.no%type,
n stud.name%type,
mark1 stud.m1%type,
mark2 stud.m2%type);
srec studrec;
total number(4);
ave number(5,2);
result char(5);
grade char(12);
begin
open c1;
loop
total:=srec.mark1+srec.mark2;
ave:=total/2;
result:='PASS';
else
result:='FAIL';
end if;
if ave>=75 then
grade:='Distinction';
grade:='First';
grade:='second';
else
grade:='Nill';
end if;
end loop;
close c1;
end;
Sql>Set serveroutput on
Result:
Aim:
Procedure:
Step 2: Column ID to have a key column Date where you will store day column Pay Head.
Step 5: Do same process for create, insert, previous, next, save and exit.
SQL Commands:
SQL> Create table pay( name varchar(20), eno number(3), design varchar(20), Bpay
number(7,2), DA number(7,2), CCA number(7,2), Allow number(7,2), GP number(7,2), DED
number(7,2), Netpat number(7,2));
Table created.
CREATE_RECORD;
BLOCK NAME: PAY
DELETE_RECORD;
PREVIOUS_RECORD;
NEXT_RECORD;
FIRST_RECORD;
LAST_RECORD;
EXECUTE_RECORD;
SAVE_RECORD;
BLOCK NAME: PAY
BPAY_RECORD;
:pay.da:=:pay.bpay*0.5
:pay.cca:=pay.bpay*0.2
:pay.allow:=pay.bpay*0.1
:gp:=:bpay+:da+:cca+:allow;
Go_item(‘pay.gp’);
Result:
Aim:
Procedure:
Step 5: Do same process for create, insert, previous, next, save and exit.
SQL Commands:
SQL> create table mark(sno number(3), name varchar(20), m1 number(3), m2 number(3), total
number(3), average number(5,2), result varchar(10));
Table created.
CREATE_RECORD;
BLOCK NAME: MARK
DELETE_RECORD;
PREVIOUS_RECORD;
NEXT_RECORD;
BLOCK NAME: MARK
FIRST_RECORD;
LAST_RECORD;
EXECUTE_RECORD;
BLOCK NAME: MARK
SAVE_RECORD;
TOTAL_RECORD;
: mark.average := :mark.total/2.0;
Go_item(‘mark.average’);
AVERAGE_RECORD;
If(:mark.m1>50.00 and :mark2.m2>50.00) then
:mark.result := ‘PASS’;
ELSE
:mark.result :=’FAIL’;
End if;
Go_item(‘mark.result’);
Result:
Thus the Mark sheet Process has been executed using forms.