Professional Documents
Culture Documents
Of
Computer Science & Engineering
Data Base Management Systems Lab Manual
In-charge
Prepared by:
HOD
Approved &
Reviewed by:
Principal
Issued by:
w.e.f Date:
DBMS LAB
STREAM
CSE
H.O.D
INDEX
S. No
Contents
Page. no
Lab Objective
Guidelines to Students
9
10
Background Theory
15
21
PL-Sql Programs
51
89
References
95
10
LAB OBJECTIVE
Upon successful completion of this Lab the student will be able to:
Creating database objects
Modifying database objects
Manipulating the data
Retrieving the data from the database server
Performing database operations in a procedural manner using pl/sql
Performing database operations (create, update, modify, retrieve, etc.,)
using front-end tools like D2K.
Design and Develop applications like banking, reservation system, etc.,
RAM
256 MB
Hard Disk
40 GB
Mouse
Optical Mouse
Present
Software
All systems are configured in DUAL BOOT mode i.e., Students can boot
from Windows XP or Linux as per their lab requirement. This is very useful
for students because they are familiar with different Operating Systems so
that they can execute their programs in different programming
environments.
Latest Technologies like DOT NET and J2EE are installed in some systems.
Before submitting their final project, they can start doing mini project from
2nd year onwards.
Balaji Institute of Technology and Science
5
25 min.
100 mins.
Writing of the experiment in the Observation Book :
The students will write the todays experiment in the Observation book as
per the following format:
a) Name of the experiment/Aim
b) Software/Hardware required
c) Algorithm
d) Source Program
e) Test Data
a. Valid data sets
b. Limiting value sets
c. Invalid data sets
f) Results for different data sets
g) Viva-Voc Questions and Answers
h) Errors observed (if any) during compilation/execution
i) Signature of the Faculty
Balaji Institute of Technology and Science
Guidelines to Students
Equipment in the lab for the use of student community. Students need to
maintain a proper decorum in the computer lab. Students must use the
equipment with care. Any damage is caused is punishable.
Students are required to carry their observation / programs book with
completed exercises while entering the lab.
Students are supposed to occupy the machines allotted to them and are not
supposed to talk or make noise in the lab. The allocation is put up on the
lab notice board.
Lab can be used in free time / lunch hours by the students who need to use
the systems should take prior permission from the lab in-charge.
Lab records need to be submitted on or before date of submission.
i)
Create a view which lists out the bill_no, bill_date, cust_id,
item_id, price, qty_sold, amount
Create a view which lists the daily sales date wise for the last
one week
2
10
11
12
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Additional Programs
S. No
13
14
Background Theory
Oracle workgroup or server is the largest selling RDBMS product.it is estimated
that the combined sales of both these oracle database product account for aroud
80% of the RDBMSsystems sold worldwide.
These products are constantly undergoing change and evolving. The natural
language of this RDBMS product is ANSI SQL,PL/SQL a superset of ANSI
SQL.oracle 8i and 9i also under stand SQLJ.
Oracle corp has also incorporated a full-fledged java virtual machine into its
database engine.since both executable share the same memory space the JVM
can communicate With the database engine with ease and has direct access to
oracle tables and their data.
SQL is structure query language.SQL contains different data types those are
1. char(size)
2. varchar2(size)
3. date
4. number(p,s)
5. long
6. raw/long raw
DDL commands:
1. The Create Table Command: - it defines each column of the table uniquely.
Each column has minimum of three attributes, a name , data type and size.
Syntax:
Create
table
<table
<datatype><size>));
name>
(<col1>
<datatype>(<size>),<col2>
Ex:
create table emp(empno number(4) primary key, ename char(10));
2. Modifying the structure of tables.
a)add new columns
Syntax:
Balaji Institute of Technology and Science
15
Alter
table
<tablename>
col>datatype(size));
Ex:
alter table emp add(sal number(7,2));
3. Dropping a column from a table.
Syntax:
Alter table <tablename> drop column <col>;
Ex:
alter table emp drop column sal;
4. Modifying existing columns.
Syntax:
Alter table <tablename> modify(<col><newdatatype>(<newsize>));
Ex:
alter table emp modify(ename varchar2(15));
5. Renaming the tables
Syntax:
Rename <oldtable> to <new table>;
Ex:
rename emp to emp1;
6. truncating the tables.
Syntax:
Truncate table <tablename>;
Ex:
trunc table emp1;
7. Destroying tables.
Syntax:
Drop table <tablename>;
Ex:
drop table emp;
Balaji Institute of Technology and Science
16
DML commands:
8. Inserting Data into Tables: - once a table is created the most natural thing
to do is load this table with data to be manipulated later.
Syntax:
insert into <tablename> (<col1>,<col2>) values(<exp>,<exp>);
9. Delete operations.
a) remove all rows
Syntax:
delete from <tablename>;
b) removal of a specified row/s
Syntax:
delete from <tablename> where <condition>;
10. Updating the contents of a table.
a) updating all rows
Syntax:
Update <tablename> set <col>=<exp>,<col>=<exp>;
b) updating seleted records.
Syntax:
Update
<tablename>
where <condition>;
set
<col>=<exp>,<col>=<exp>
17
18
DQL Commands:
12. Viewing data in the tables: - once data has been inserted into a table, the
next most logical operation would be to view what has been inserted.
a) all rows and all columns
Syntax:
Select <col> to <col n> from tablename;
Select * from tablename;
13. Filtering table data: - while viewing data from a table, it is rare that all the
data from table will be required each time. Hence, sql must give us a method of
filtering out data that is not required data.
a) Selected columns and all rows:
Syntax:
select <col1>,<col2> from <tablename>;
b) selected rows and all columns:
Syntax:
select * from <tablename> where <condition>;
c) selected columns and selected rows
Syntax:
select <col1>,<col2> from <tablename> where<condition>;
14. Sorting data in a table.
Syntax:
Select * from <tablename> order by <col1>,<col2> <[sortorder]>;
DCL commands:
Oracle provides extensive feature in order to safeguard information stored in its
tables from unauthoraised viewing and damage.The rights that allow the user of
some or all oracle resources on the server are called privileges.
a) Grant privileges using the GRANT statement
The grant statement provides various types of access to database objects such as
tables,views and sequences and so on.
Syntax:
GRANT <object privileges>
ON <objectname>
TO<username>
Balaji Institute of Technology and Science
19
20
item_id: integer,
21
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
ORACLE
Cust_id
NOT NULL
NUMBER(4)
Item_name
VARCHAR2(15)
PRICE
NUMBER(6,2)
22
23
ITEMID
--------5001
BILLNO
--------332
d) List the total Bill details with the quantity sold, price of the item and the
final amount
SQL> select i.price, s.qty,(i.price*s.qty) total from item I, sale s where
i.itemid=s.itemid;
PRICE
------120
20
5
10
350
QTY
----2
3
2
1
4
TOTAL
-------240
60
10
10
1400
e) List the details of the customer who have bought a product which has a
price>200
SQL> select c.custid, c.custname from customer c, sale s, item i where
i.price>200 and
c.custid=s.custid and i.itemid=s.itemid;
CUSTID
--------4
CUSTNAME
-------------duffy
f) Give a count of how many products have been bought by each customer
SQL> select custid, count(itemid) from sale group by custid;
CUSTID
---------1
3
4
5
COUNT(ITEMID)
--------------------2
1
1
1
24
ITEMNAME
------------pencil
i)
Create a view which lists out the bill_no, bill_date, cust_id,
item_id, price, qty_sold, amount
SQL>create view cust as (select s.billno, s.billdate, c.custid, i. iitemid,
i.price, s.qty from customer c,sale s item I where c.custid=s.custid
and i.iemid=s.itemid);
view created.
SQL>select * from cust;
BILLNO BILLDATE
CUSTID ITEMID PRICE QTY
3432
12-JAN-06
3
3244
120 2
4424
20-FEB-06
1
3456
20
3
332
13-MAR-06 1
1234
5
2
2343
10-MAR
5
5001
10
1
1331
11-MAR-06 4
76776
350 4
j) Create a view which lists the daily sales date wise for the last one
week
Viva-Voce:
Q1. What is SQL?
Ans: Structured Query Language
2. What is database?
A database is a logically coherent collection of data with some inherent
meaning, representing some aspect of real world and which is designed, built
and populated with data for a specific purpose.
25
Advantages of DBMS?
Redundancy is controlled.
Unauthorised access is restricted.
Providing multiple user interfaces.
Enforcing integrity constraints.
Providing backup and recovery.
6.
26
27
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle
HARISH
BALAJI
RAKESH
PAVAN
JOYCE
28
29
ISS_NO
ISS_DATE
MEM_NO
BOOK_NO
NOT NULL
43
05-JAN-06
5443
4523
81
28-DEC-05
5441
8723
22
08-DEC-05
5440
7821
53
07-JAN-06
5442
9123
35
06-JAN-06
5444
2342
c) List all the student names with their membership numbers
SQL> select s.studname, m.memno from student s, membership m where
m.studno=s.studno;
STUDNAME MEMNO
------------- -------abhijeet
1001
arun
1002
arvind
1003
ashish
1004
ashwin
1005
d) List all the issues for the current date with student and Book names
SQL> select i.issno, s.studname, b.bookname from iss_rec I, membership m,
student s, book b
2 where i.memno=m.memno and m.studno=s.studno and
i.issdate=to_char(sysdate);
ISSNO
------13
STUDNAME BOOKNAME
-------------------------arvind
P&S
e) List the details of students who borrowed book whose author is CJDATE
SQL> select * from student where studno in(select studno from membership
where memno in
2 (select memno from iss_rec where bookno in(select bookno from book where
author=CJDATE)));
STUDNO
STUDNAME
30
------------ashwin
f) Give a count of how many books have been bought by each student
SQL> select s.studno, count(i.bookno) from student s.membership m, book b, 2
iss_rec I where s.studno=m.studno and b.bookno=i.bookno group by s.studno;
STUDNO
---------501
502
503
504
505
COUNT(I.BOOKNO)
----------------------5
5
5
5
5
j) Create a view which lists the daily issues-date wise for the last one week
31
Viva-Vice:
1. Describe the three levels of data abstraction?
The are three levels of abstraction:
Physical level: The lowest level of abstraction describes how data are stored.
Logical level: The next higher level of abstraction, describes what data are
stored in database and what relationship among those data.
View level: The highest level of abstraction describes only part of entire
database.
2. Define the "integrity rules"
There are two Integrity rules.
Entity Integrity: States that Primary key cannot have NULL value
Referential Integrity: States that Foreign Key can be either a NULL
value or should be Primary Key value of other relation.
3. What is extension and intension?
Extension It is the number of tuples present in a table at any instance. This is
time dependent.
Intension It is a constant value that gives the name, structure of table and the
constraints laid on it.
4. What is System R? What are its two major subsystems?
System R was designed and developed over a period of 1974-79 at IBM
San Jose Research Center. It is a prototype and its purpose was to demonstrate
that it is possible to build a Relational System that can be used in a real life
environment to solve real life problems, with performance at least comparable to
that of existing system.
Its two subsystems are
Research Storage
System Relational Data System.
5. How is the data structure of System R different from the relational structure?
Unlike Relational systems in System R
Domains are not supported
Enforcement of candidate key uniqueness is optional
Enforcement of entity integrity is optional
Referential integrity is not enforced
6. What is Data Independence?
Data independence means that the application is independent of the
storage structure and access strategy of data. In other words, The ability to
Balaji Institute of Technology and Science
32
33
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle
34
35
401
500
402
200
403
600
404
400
405
1200
d) List all the employee names who joined after particular date
SQL>select e,empname from employee e,paydet p where e.empid=p.empid and
p.doj>=05-mar-06;
EMPNAME
AVINASH
NITIN
PHALGUN
e) List the details of employees whose basic salary is between 10,000 and
20,000
sqL> Select empid,empname from employee where salary between 10000 and
20000;
EMPID EMPNAME
.
402
AKHILA
403
aaaaaaaa
EMPID EMPNAME
.
AKHILA
f) Give a count of how many employees are working in each department
Balaji Institute of Technology and Science
36
1
200
1
400
1
500
1
600
1
1200
g) Give a names of the employees whose netsalary>10,000
SQL> select empname from employee where empid in(select empid from paydet
where basic-deduction>10000);
EMPNAME
AVINASH
AKHILA
HARISH
NITIN
PHALGUN
h) List the details for an employee_id=5
SQL> select * from employee where empid=5;
EMPID
EMPNAME
-----------------------------------------5
Coulthard
i)
j)
Viva-Vice:
13. What is Data Model?
A collection of conceptual tools for describing data, data relationships data
semantics and constraints.
Balaji Institute of Technology and Science
37
What is an Entity?
It is a 'thing' in the real world with an independent existence.
17.
18.
38
39
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle
40
920
50
981
51
897
52
820
53
928
54
SQL>create
table cassette(cass_no number(5) primary key,
Cass_name varchar2(15),language varchar2(15));
SQL>desc cassette;
Name
Null?
Type
..
CASS_NO
NOT NULL
NUMBER(5)
CASS_NAME
VARCHAR2(15)
LANGUAGE
VARCHAR2(15)
SQL>insert into cassette values(&cass_no,&cass_name,&language);
SQL>select * from cassette;
CASS_NO
CASS_NAME
LANGUAGE
1
tagore
telugu
2
the lion king
English
3
anniyan
tamil
4
indra
telugu
5
lord of rings
English
SQL>create table issu_rec(iss_no number(5) primary key,iss_date date,mem_no
number(5)references memship(mem_no),cass_no number(5) references
cassette(cass_no));
SQL>desc issu_rec;
Name
Null?
Type
...
ISS_NO
NOT NULL
NUMBER(5)
ISS_DATE
DATE
MEM_NO
NUMBER(5)
CASS_NO
NUMBER(5)
SQL>select * from issu_rec;
ISS_NO
ISS_DATE
MEM_NO
CASS_NO
41
22
23
26
3
34
07-JAN-06
10-JAN-00
10-JAN-06
01-JAN-06
31-DEC-05
920
981
897
820
928
42
What is an attribute?
It is a particular property, which describes the entity.
22.
24.
What is Relationship?
It is an association among two or more entities.
25.
43
f)
g)
h)
i)
j)
44
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle
null?
NOT NULL
Type
NUMBER(5)
VARCHAR2(20)
VARCHAR2(20)
STUD_NAM
LEON
VIKAS
MATHEW
HANSEN
ALEXIS
CLASS
CSE
CSIT
ECE
MECH
EEE
null
type
VARCHAR2(10)
VARCHAR2(20)
45
Name
null
MACH_NO
LAB_NO
DESCRIPTION
NOT NULL
NUMBER(5)
NUMBER(5)
VARCHAR2(20)
Null?
-------
Type
--------NUMBER(5)
NUMBER(5)
VARCHAR2(20)
MACH_NO
-----------23
87
78
12
12
DOWEEK
-----------sat
mon
tue
wed
thu
c) List all the machine allotments with the student names, lab and machine
numbers
SQL>select s.studname,l.machno from student1 s,lab l,allotment a where
a.machno=l.machno and a.studno=s.studno;
Balaji Institute of Technology and Science
46
1
UNIX
MONDAY
22
UNIX
TUESDAY
3
XP
WEDNESDAY
4
WINDOWS
THRUSDAY
5
ME
FRIDAY
e) Give a count of how many machines have been allocated to the CSIT class
SQL>select count(machno)from allotment where studno in(select studno from
student1 where class=CSIT);
COUNT (MACHNO)
..
1
f) Give a machine allotment etails of the stud_no 5 with his personal and
class details
SQL>select a.studno,a.machno,s.studname,s.class from allotment a,student1
s where a.studno=s.studno and a.studno=503;
STUDNO
MACHNO
STUDNAME
CLASS
503
5
ARVIND
CSE
g) Count for how many machines have been allocatedin Lab_no 1 for the
day of the week as Monday
h) How many students class wise have allocated machines in the labs
Balaji Institute of Technology and Science
47
2
CSE
1
ECE
1
EEE
1
IT
i) Create a view which lists out the stud_no, stud_name, mach_no, lab_no,
dayofweek
j) Create a view which lists the machine allotment details for Thursday
Viva-Vice:
26.
25.
27.
48
49
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Algorithm:
Step 1: Declare the variable A, B, and C.
Step 2: Store the valid data.
Step 3: Compare variable A with B and A with C
Step 4: If the value stored in variable A is big, it displays A is Big. (IF
conditional statement should be used)
Step 5: Compare variable B with C
Step 6: If the value stored in variable B is big, it displays B is Big.
Step 7: other wise it displays C is Big
Declare
A number;
B number;
C number;
Begin
A:=&a;
B:=&b;
C:=&c;
If a > b && a> c then
Dbms_output.put_line( A is big );
Else
Balaji Institute of Technology and Science
50
51
What is Record-at-a-time?
The Low level or Procedural DML can specify and retrieve each record from
a set of records. This retrieve of a record is said to be Record-at-a-time.
35.
52
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Algorithm:
Step
Step
Step
Step
Step
Step
Step
1:
2:
3:
4:
5:
6:
7:
53
1:
2:
3:
4:
5:
6:
7:
/* using while */
Declare
I number;
Begin
I:=1;
While (I<=10)
loop
Dbms_output.put_line(I);
I:=I+1;
End loop;
End;
54
55
What is normalization?
It is a process of analysing the given relation schemas based on their
Functional Dependencies (FDs) and primary key to achieve the properties
Minimizing redundancy
Minimizing insertion, deletion and update anomalies.
40.
56
57
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, Pl-SQL
Algorithm:
Step 1: Declare the variable N, S, D and DUP.
Step 2: Store the value in var. N and var. DUP..
Step 3: check for the value of N, which is not equal to 0.
Step 4: divide value stored in N by 10 and store it var. D. (D=n%10).
Step 5: the reminder will be multiply 3 times and store it in Var. S.
Step 6: The coefficient will be calculated using FLOOR function. And store it
in var. N.
Step 7: repeat the Steps 3, 4, 5, and 6 till loop will be terminated.
Step 8: Check whether the stored value and calculated values are same
Step 9: if both the values are same, then display The given number is
Armstrong
Step 10: Otherwise display it is not Armstrong and terminate the
loop.
Declare
N number;
S number;
D number;
Begin
N:=&n;
S:=0;
While(n!=0)
Loop
D=n%10;
Balaji Institute of Technology and Science
58
45.
What is 2NF?
A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully
functionally dependent on primary key.
47.
What is 3NF?
A relation schema R is in 3NF if it is in 2NF and for every FD X
59
What is 4NF?
A relation schema R is said to be in 4NF if for every Multivalued dependency
that holds over R, one of following is true
X is subset or equal to (or) XY = R.
X is a super key.
60
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
I number;
J number;
C number;
Begin
While(i<=100)
Loop
C:=0;
J:=1;
While(j<=i)
Loop
If(floor(i%j)=0) then
C:= C+1;
End if;
J:=j+1;
End loop;
If(c=2) then
Dbms_output.put_line(i);
Balaji Institute of Technology and Science
61
What is 5NF?
A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ..., Rn} that
holds R, one the following is true
Ri = R for some i.
The join dependency is implied by the set of FD, over R in which the left side is key of R.
51. What is Domain-Key Normal Form?
A relation is said to be in DKNF if all constraints and dependencies that should hold on the the
constraint can be enforced by simply enforcing the domain constraint and key constraint on the
relation.
52. What are partial, alternate,, artificial, compound and natural key?
Partial Key:
It is a set of attributes that can uniquely identify weak entities and that are related to same
owner entity. It is sometime called as Discriminator.
Alternate Key:
All Candidate Keys excluding the Primary Key are known as Alternate Keys.
Artificial Key:
If no obvious key, either stand alone or compound is available, then the last resort is to
simply create a key, by assigning a unique number to each record or occurrence. Then this is known as
developing an artificial key.
Compound Key:
Balaji Institute of Technology and Science
62
63
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
I number;
Begin
I:=1;
If(i>=0) then
GOTO here;
Else
Dbms_output.put_line( I is negative);
End if;
<<here>>
Dbms_output.put_line( I is positive);
End;
Valid Test Data
OUTPUT:
I is positive
Viva-Vice:
54. What is system catalog or catalog relation? How is better known as?
Balaji Institute of Technology and Science
64
65
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
My_Empno emp.empno%type;
My_Ename emp.ename%type;
My_Emprow
emp%rowtype;
No number;
Begin
No:=&no;
Select empno,ename
empno=no;
into
my_empno,my_ename
from
emp
where
If(SQl%rowcount=1) then
Dbms_output.put_line(empno
my_ename);
is
||
my_empno
||
ename
is
||
Else
Dbms_output.put_line( error);
End if;
Select * into my_emprow from emp where empno=no;
If(SQl%rowcount=1) then
Dbms_output.put_line(empno is || my_emprow.empno || ename is ||
my_emprow.ename);
Else
Balaji Institute of Technology and Science
66
67
68
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
A number
B number;
C number;
Begin
A:=&a;
B:=&b;
C:=a/b;
Dbms_output.put_line(division is || C);
Exception
If (ZERO_DIVIDE) then
Dbms_output.put_line(b could not be zero);
End if;
End;
Valid Test Data:
Enter the value for a:
10
Enter the value for b:
Balaji Institute of Technology and Science
69
14. Write
exceptions
program
to
demonstrate
user
defined
HW/SW requirements:
Balaji Institute of Technology and Science
70
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
A number
B number;
C number;
Mydivide_zero EXCEPTION;
Begin
A:=&a;
B:=&b;
If(B=0) then
Raise Mydivide_zero;
else
C:=a/b;
Dbms_output.put_line(division is || C);
End if;
Exception
If (mydivide_zero) then
Dbms_output.put_line(b could not be zero);
End if;
End;
Valid Test Data:
Enter the value for a:
Balaji Institute of Technology and Science
71
Database files
Control files
Redo logs
The most important of these are the database files where the actual data resides. The control
files and the redo logs support the functioning of the architecture itself.
All three sets of files must be present, open, and available to Oracle for any data on the database to be useable. Without these files, you cannot
access the database, and the database administrator might have to recover some or all of the database using a backup, if there is one.
73
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
Declare
Cursor my_cur is select empno,sal from emp;
Xno emp.empno%type;
Xsal emp.sal%type;
C number;
Begin
Open my_cur;
C:=0;
Loop
Fetch my_cur into xno,xsal;
If(xsal<1000) then
Update emp set sal=3000 where empno=xno;
C:=c+1;
Else if(xsal>=2000) and xsa<3000) then
Balaji Institute of Technology and Science
74
End loop;
Close my_cur;
Dbma_output.put_line(c||records have been successfully updated);
End;
Sql>@a.sql;
records have been successfully updated
pl/sql procedure successfully completed.
Valid Test Data
Before executing the cursor, the records in emp table as follows
Sql>select * from emp;
OUTPUT:
EMPNO ENAME
----------------------------------------------------------------7369 SMITH
CLERK
7499 ALLEN
SALESMAN
7698 20-FEB-81
1600
300
30
7521 WARD
SALESMAN
7698 22-FEB-81
1250
500
30
7902 17-DEC-80
MGR HIREDATE
SAL
2000
COMM
20
DEPTNO
MANAGER
7839 02-APR-81
2975
20
75
MANAGER
7839 01-MAY-81
2850
30
14 rows selected.
Viva-Vice:
81. What are database files, control files and log files. How many of these files should a database have
at least? Why?
Database Files
The database files hold the actual data and are typically the largest in size. Depending
on their sizes, the tables (and other objects) for all the user accounts can go in one database filebut
that's not an ideal situation because it does not make the database structure very flexible for controlling
access to storage for different users, putting the database on different disk drives, or backing up and
restoring just part of the database.
You must have at least one database file but usually, more than one
files are used. In terms of accessing and using the data in the tables and other
objects, the number (or location) of the files is immaterial.
The database files are fixed in size and never grow bigger than the size at which they
were created
Control Files
The control files and redo logs support the rest of the architecture. Any database
must have at least one control file, although you typically have more than one to guard against loss.
The control file records the name of the database, the date and time it was created, the location of
the database and redo logs, and the synchronization information to ensure that all three sets of files
are always in step. Every time you add a new database or redo log file to the database, the
information is recorded in the control files.
Redo Logs
Any database must have at least two redo logs. These are the journals for the database;
the redo logs record all changes to the user objects or system objects. If any type of failure occurs, the
changes recorded in the redo logs can be used to bring the database to a consistent state without losing
any committed transactions. In the case of non-data loss failure, Oracle can apply the information in
the redo logs automatically without intervention from the DBA.
The redo log files are fixed in size and never grow dynamically from the size at which
they were created.
Balaji Institute of Technology and Science
76
77
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
78
79
80
81
HW/SW requirements:
Processor
RAM
256 MB
Hard Disk
40 GB
Software
Oracle, PlSQL
82
83
/*add_fun specification*/
Declare
Result number;
Begin
Result:=add_fun(10,20);
Dbms_output.put_line(the sum of 10 and 20 is||result);
End;
Sql>/
The sum of 10 and 20 is 30
Pl/sql procedure successfully completed.
/*create a function which count total no.of employees having salary less
than 6000.*/
/*function body*/
Create or replace function count_emp(esal number)return number as
Cursor vin_cur as Select empno,sal from emp;
Xno emp.empno%type;
Xsal emp.sal%type;
C number;
Begin
Open vin_cur;
C:=0;
loop
Balaji Institute of Technology and Science
84
85
What are Armstrong rules? How do we say that they are complete and/or sound
The well-known inference rules for FDs
Reflexive rule :
If Y is subset or equal to X then X
Y.
Augmentation rule:
If X
Y then XZ
YZ.
Transitive rule:
If {X Y, Y
Z} then X
Z.
Decomposition rule :
If X
YZ then X
Y.
Union or Additive rule:
If {X
Y, X
Z} then X
YZ.
Pseudo Transitive rule :
If {X
Y, WY
Z} then WX
Z.
Of these the first three are known as Amstrong Rules. They are sound because it is enough if a
set of FDs satisfy these three. They are called complete because using these three rules we can generate
the rest all inference rules.
103.
87
world .
Retroactive Update:
The updates that are applied to database after it becomes effective in real world .
Simulatneous Update:
The updates that are applied to database at the same time when it becomes
effective in real world .
106.
88
89
91
REFERENCES:
SCOTT Urman, oracle 8i-PL/SQL programming,TMH-2000
Loney, oracle 8i-the complete reference,TMH-2000
Loney, oracle 9i-the complete reference,TMH-2000
Bayross, oracle Teach Your Self SQL/PLSQL using oracle 8i and 9i with
SQLJ, BPB, 2002.
Abbey, oracle 8i-A beginners guide,TMH-2000.
92
Annexure - 1
:
:
______________________________________
_________________________
_________________________
_________________________
________________
Student Signature
Balaji Institute of Technology and Science
________________
Faculty Signature
93
Annexure - 2
Index Page
S. No.
Date
Program / Experiment
Page
No.
Sign /
Remarks
Annexure - 3
94
Department of ________________________
This is to certify that
Name
Class / Year /
Semester
Roll No.
Subject
Branch
:
:
______________________________________
_________________________
_________________________
_________________________
________________
Department Head
95