You are on page 1of 124

c 

›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )


CO N TEN T 

PART-1 =====üDBMS PAGE.NO


Π 


  

 

  


 


 

   

PART-2 =====üSQLÎ

â   

   

  !" !# $!%$!& '

 (  ! ) $


  

*+  

*+ ,-.  

*+-/  

*+  

0-1   

2-1'Œ23 241  1 13 


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
  !" !#$)% '


   

*Number Function , *Character Function , *Date Function & *Group Function

2 

*2'+3 

5( 
 

6  

Π7 

 (  )-/  

   

1  

PART-3 =====üPL/SQLÎ

Π -/  

  


8  

5)$   

-/  

  

 

  

$ 


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p 

 à à  PROGRAMSp



 


Ô Create a table to represent SB _account of a bank consisting of
 account_no,customer_name & bal_amount. Write a PL/SQL block to


implement deposit & withdraw.Withdraw shoult not be allowed if the
 balance goes below Rs.1000.

 Create the following Two tables:


 College_info, consisting of field s :- (college_code,college_name,address)
 Faculty_info, consisting of fields :-(college_code,faculty_code

 ,faculty_name ,qualification, experiences_in_no_of_years,address.) The
 field college_code is foreign key.

 (A)Design a form to accept the data from the user.
 (B)Generate queries ti do th following:

 ( i)List all those faculty members whose experience is greater than or
 equal to 10years & have M.TECH degree.

 (ii) List all those faculty members,who have atleast 10years of experience


but,do not have M.TECH degree.

  Create the following tables for Library Information system:
 BOOK:(book_no,title,publisher,author,status) . STATUS could be

 issued,present in the library,sent for binding and cannot be issued.
 Write a trigger which sets the status of a book to ³cannot be issued´,if it

 is a published 20years back.

 Create the BOOK table as in the 3rd program add one field as
 (data_of_purchase), AND Status could be as same as in that table.

 (A) Create a form to accept the data from the user with appropriate


validation checks.
 (B) Generate queries to do the following:-

 (i) List all those books which are new arrivals.The books which are
 acquired during the last 6 months are categorized as new arrivals.

 (ii) List all those books that cannot be issued and purchased 20 years
 back (or) ago.




 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ù Create the following tables:-
 Student(roll_no,name date_of_birth,course_id)

 Cource(cource_id,name,fee,duration).


(A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Generate queries to do the following:-
 (i) List all those students who are greater than 18 years of age and have

 opted for MCA cource.
 (ii) List all those cources whose fee is greater than that of MCA cource.

 Create the following tables:-

 Item(item_code,item_name,qty_in_stock,reorder_level)
 Supplier(supplier_code,supplier_name,address)

 Can_supply(supplier_code,item_code)
 (A) Create a form to accept the data from the user with appropriate

 validation checks.


(B) Generate queries to do the following:-
 (i) List all those suppliers who can supply the given item.


(ii) List all those items which cannot be supplied by given company.

 Create the following tables:-
 Branch(branch_id,branch_name,customer_city,customer_id)

 Customer(customer_id,customer_name,customer-city,branch_id).
 (A) Create a form to accept the data from the user with appropriate

 validation checks.
 (B) Generate queries to do the following:-

 (i)List all those customers who live in the same city as the branch in


which they have account.
 (ii) List all those customers who have an account in a given branch city.

 Create the following tables:-

 BOOK(book_number,title,publisher,year,data_of_purchase,status)
 MEMBER(member_id,member_name,number_of_books_issued,max_limit

 ).
 BOOK_ISSUE(book_number,member_id,data_of_issue)

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Generate queries to do the following:-
 (i) List all those books which are due from the students to be returned. A



 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
 book is considered to be due ,if it has been issued 15 days back and yet

 not returned.
 (ii) List all those members who cannot be issued any more books.

 Create the following tables:-

 BOOK(book_number,title,publisher,year,data_of_purchase,status)
 MEMBER(member_id,member_name,number_of_books_issued,max_limit

 ,status)
 BOOK_ISSUE(book_number,member_id,data_of_issue,due_date)

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Write a PL/SQL to list all those students who are defaulters. A
 student is consider to be a defaulter if he has not returned a book even

 after due_date.
 (C) Write a trigger to set the status of the status of students to ³black

 listed´ if they have taken book but not returned even after one(1) year.

Ô Create the following tables:-

 Student(roll_no,s_name,category,district,state)
 Student_rank(roll_no,marks,rank)

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Generate queries to do the following:-
 (i) List names of the students who are having the same rank but they

 should reside in different districts.
 (ii) List details of students they belongs to same category with same rank.


ÔÔ Create the following tables:-
 Student(roll_no,name date_of_birth,course_id)

 Cource(cource_id,name,fee,duration).
 (A) Create a form to accept the data from the user with appropriate

 validation checks.
 (B) Generate queries to do the following:-

 (i) List all those students who are between18-to-19 years of age and have
 opted for MCA course.

 (ii) List all those courses in which number of students are less than 10.

Ô Create the following tables:-


Student(roll_no,name date_of_birth,course_id).


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
 Cource(cource_id,name,fee,duration,status).

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Write PL/SQL procedure to do the following:-
 Set the status of course to ³not offered´ in which the number of

 candidates is less than 5.
Ô
 Create the following tables:-

 Item(item_code,item_name,qty_in_stock,reorder_level)
 Supplier(supplier_code,supplier_name,address)

 Can_supply(supplier_code,item_code)
 (A) Create a form to accept the data from the user with appropriate

 validation checks.
 (B) Write PL/SQL procedure to do the following:-

 Generate a report to list the items whose qty-in-stock is less than or equal
 to their reorder-levels.

Ô

Create the following tables:-
 Item(item_code,item_name,qty_in_stock,reorder_level)


Supplier(supplier_code,supplier_name,address,status)
 Can_supply(supplier_code,item_code)

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Write PL/SQL procedure to do the following:-
 Set the status of the supplier to ³important´,if the supplier can supply

 more then than five(5) items.
Ôù
 Create the following tables:-
 Student(roll_no,s_name,subject_opted)

 Subject_rank(subject_code,subject_name,faculty_code,specialization)


Faculty(faculty_code,faculty_name,specialization)
 (A) Create a form to accept the data from the user with appropriate


validation checks.
 (B) Write PL/SQL procedure to do the following:-

 Set the status of the student to ³not offered´,if the subject is not opted by
 atleast 5 students.

 Ô Create the following tables:-

 Student(roll_no,s_name,subject_opted)



 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
 Subject_rank(subject_code,subject_name,faculty_code,specialization)

 Faculty(faculty_code,faculty_name,specialization)
 (A) Create a form to accept the data from the user with appropriate

 validation checks.
 (B) Write PL/SQL procedure to do the following:-

 Set the status of the student to ³not offered´,if the subject is not offered

by any of the faculty members.
Ô

 Create the following tables:-
 Student(roll_no,s_name,subject_opted)

 Subject_rank(subject_code,subject_name,faculty_code)
 Faculty(faculty_code,faculty_name,specialization)

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Generate queries to do the following:-
 (i) Find the number of students who have enrolled for the subject

 ³DBMS´.
 (ii) Find all those subjects which are not offered by any faculty members.
Ô


Create the ABOVE tables of program no.18 to do the following :-
 (A) Create a form to accept the data from the user with appropriate

 validation checks.
 (B) Generate queries to do the following:-

 (i) Find the number of students who have enrolled for the subject ³OS´.
 (ii) Find all those subjects who opted for more than 5 subjects.
 Ô
 Create the ABOVE tables of program no.18 to do the following :-

 (A) Create a form to accept the data from the user with appropriate
 validation checks.

 (B) Generate queries to do the following:-


(i) Find the number of students who have ³not´ enrolled for the subject
 ³DBMS´.


(ii) Find all those subjects which are offered by MORE than one(1)
 faculty members.

 Create the following tables:-

 Student(roll_no,marks,category,state)
 Student-rank(roll_no,marks,rank)

 (A) Create a form to accept the data from the user with appropriate



 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
 validation checks.

 (B) Generate queries to do the following:-
(i) List all those students who have come from ³tamilnadu´ state and
secured a rank above 100.
(ii) L ist all those students who come from ³andhra pradesh´ state and
belong to given category who have secured a rank above 100.ppppppppppppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

Introduction to DBMS
ppppppppppppppppp

ppp p pp p


pppp p
p pppppppp pppp pp
 p ppp pp pppp ppp
 ppppppp ppppp
p pp pp
pppppppppppppppppp p pp  pppp pp
pppp pppp pp
pppppp ppppp
ppppp pp p pp
 ppp pppp p p ppp
pp ppp pp ppppp
 pp pppp
pppppppppppppppppppppppppppp p
ppppppppppppppppp p pppp pp
 p pp p pp p pp p
p
p
p p p ppppppppppp ORp

O
   
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.
    ORÿ
It is a collection of programs that enables user to create and maintain a database. In
other words it is general-purpose software that provides the users with the processes
of defining, constructing and manipulating the database for various applicationsÎ
p
p
Advantages of DBMS!p
p
^p " p p   p
 p p pp p
p
^p # p ppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
^p # p p p p p
p
^p # p p  p
p
^p "pppp
p
DATA ABSTRACTION!ppppp
pppppppp
ppppp
pppppppp p pp p pp$ppp$p
p ppp p pp pp$pp pp p p
 pppp ppp pp%p pp
pppp ppp pp% pp pp
pppppppp pp pp
p$ppp pp p
p
Physical Level!p
ppppppppppppppppp p
ppppppppppppp$pppp pp pp p p
pp p
p
Conceptual Level:
p p
ppppppppppppppppp%pppp p$p pp
 p ppp p pppp%p$p
pppp p p p$pp  p$ppppp
&ppp p
p
View Level:
p
ppppppppppppppp p pppppp
p
p
DATA MODELS!p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppppppppppppppppppppp p p ppp  ppppppp
p p ppp$p p ppp
 ppp$pp
pppppppppppppppppppp
^p '(p pp p
^p " p pp p
^p # p p pp
p
Object oriented logical models:
p
pppppppppp pp pp p pppp p$pp
ppp$  p&$p pp
ppppppppp
^p ) p"p 
)"p !ppp ppp$ p
p$pppppp(p
 p*)+p p*+ppp(p
^p '(p p !pppppp pppp(p
p(pppp$pp(p p
(ppp pp ppppp
(p p p
p
Record based logical models:
pppp pp pp p pppp p$pp p
p pp pp% p ppp p pp
 pp p pp p
ppppppppppppppppppppppppppppppppppppp$  p&$p p!p
p
^p Relational model!pppp p ppp p
 ppppppp$pppppp$p
,pp
^p Network model!ppp p ppp p p
pp pp p p&p$pp$ p
pp
^p Hierarchical model!pp p ppp p$p
p ppppp pp pp
p pp p p&p$pp$ ppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
^p Physical models!p pp pp p ppp$p
p
p
DATABASE FACILITIES!pp
pppppppppp
ppppppp$pp pppp  p pp !p
p
^p p p pp p pp
-p
p
^p ppp ppp
-p
p
Data definition language (DDL!pp
ppp
pppppppppppp p ppp p pppp p$pp
% p pppp p p pp

-ppppp -ppppppp
$pp ppppp p p  p
pppppppppppppppppppp pp p p pp
p pp p pppp pppp pp
-p p pp p ppppp
ppp ppppppp pp
p ppp pp$pp p
 ppp
p
Data manipulation language (DML):
p
pppppppppppppppppppppp p ppp
-ppppp
pppppp p p
ppppp ppp
ppppppppppppppppp.p"ppp ppp p
pppppppppppppppp/ppp$pppp p
pppppppppppppppp0p ppppp p
pppppppppppppppp1p  pp p ppp p
p$p pp -!pp
.p # p -p,pppp p$p pp
 p p$pppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
/p 2p# p -p,pppp p$p
pp  p$p p$pppp
p
p
3 pppp,ppppp
pppp -ppppp p, p
p
p
p
STRUCTURE OF A DBMS!pp
pppp
ppppppppppppppp(pppp pp
p
Data definition language compiler!pp
pppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppp -ppp p pp
pppppppp ppp
p
p
Data Manager!pp
ppppppppppppppppppppp
pppppppppppppppppppp ppppp$pppp
pppppp,ppp, p
pp  ppppppp+pp
$pp pp pp ppppp
ppp p
p
File Manager!p
pppppppppp ppppp p
pppp&pp, p p,pp&p
pp &pp ppp, p ppp p
pp
p
Disk manager:
p &pppp&ppp p, p pp
pp$pppp pppp
  pp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
Query Processor:p
p, ppp ppppp+p, p pp
pppppppppppppppp
ppp%ppp p  pp pppp
ppppp p ppppp  p
p, p
p
Data Files:p
ppp pppp p
p
Data Dictionary: p
p p  pppppp pp pp pp
pp ppp pp pp  ppp p
 
Different types of Keys:p
!p p(ppp pp p pppp
p pppp pp pp
p
.p Primary key:p ppp  pp p, p$p
$p ppppp pppp p# p& p
p
)%!ppppp pp p ppp p
p

/p Foreign key: pp$ppp p& ppp$pp p


p pppppppp pp& p
0p Super Key:p p p& p$ppppppp
,p pp pp& ppp$ p p& pp
ppp& p
Ex:p)pp$pppp& p

1p Candidate Key:pppp& pp$ppppppp


& ppppp& ppp  p& p
Ex: )ppp  p& p
p
pppppppppppppppppppppppppTRUCTURED UERY ANGUAGE(SQL)p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

â  


S
SQL

   ! ÿ 
    " #$
 Î"$   

 % & 
 Î
 '
 
! 
 '
 ÿ   
& 
!
 ! 
! 
 

 #  Î"$  
  
  (  &    
 
   )  
 Î

! 
! 
 

 #   &  "$*! #
    "$
)  '
  Î! & &  
  #   "$   &! &)
&%
 
! #+ 

 &  !!#
!# 
 & # Îc%) 
& 
"$
  &  !  '
  ,   !   -  
  


  ! &! )# &
 & 

  % & 
 Î.&  !
%!!)# % & &
  

 &
  & & 
  %!! !!%
#    &   
 &"$'
 Î

ORp
p
p3-pppp  pp ppp p ppp
p
ppppppppp3-pp ppppp %pp$pp3-ppp
ppppp pp p ppp
p
pppppppppppppppppppppp3-p ppp&p pp
pp p p ppp$pp pp
p p p pppppppppppppp
p
ORp
p
SQLpp p%  ppStructured Query Languagepppcomputer languagep
 pppp pppdatapprelational database management
systemsp ppp p p p p(ppp
4.54/5pp
p
3-p
 p3 p-ppp  pp pppp
ppp p pp p p3-pppp 2p pp'p
  p p p pp3-p$p p%ppp  p
p3p&ppppp pppp ppp p
 ppppp p pppppppppp
p

Procedural extensions


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
3-pp  pppp!pp, p p ppprelational databasep3-p
pp p p, ppppimperative languagepppCppBASIC.p
6$ppp%pp  p3-p$p pprocedural programming
languagep ppp$pp

p p p p ppppppppppp
ORp
pp pp
S pQ pLp# p73-7pp7see,7ppp pp
p pp pppp p' p  p p ppp
pp p p  pp8ppp3-p3-p
 ppp pp p$&p$pp pppp  p$pp
pppppp p#p%pp3-pp p
ppp$p ppp pp(p pp
 p
pppp
p
2p   p3-ppp pp p
ppp
 pp$pp p&p3-pp  p pppp
p3-p ppp p,ppppp p

SQL Statements:

3-ppp   pp


pppppppppppppppppppppppppppppppppppp.p p p
-p
pppppppppppppppppppppppppppppppppppp/p p p-
-p
pppppppppppppppppppppppppppppppppppp0pp p9p-p
9-p
pppppppppppppppppppppppppppppppppppp1pp#p-p
#-p
pppppppppppppppppppppppppppppppppppp:p p"p-p
"-p
Data Definition Language (DDL):ppppppp pp
ppppp p -ppppp p p
p
p
Data Manipulation Language (DML):pppppp p
, pppp ppp pppp p
 p pp
p
Data Control Language (DCL)!pppppp p, p
ppppppp pppp p&p
&pppppp 9-pppp p&p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Transaction control language (TCL):pppp p
 pppp&pp p p p
p
Data retrieval language (DRL):ppppp p, p
ppp pppp "-ppppp
p
p

â  
     
  
 
DD
p
    p p p
p  p p  pp p

p
pp p
pp

3p  pp p
p p pp pp
3p  pp
pp

p pp pp
3p  pp p p
pp pp
3p  pp
 pp

p
ppp   ppp  p
pp

p
p

  pp
3p pp p  p pp p  
pp
3p pp
 p p pp

DM
p
   p p p
p  p
p  p p pp p p
pp

3p pp

p p
ppp pp
3p Πpp 
p p  pppp
3p pp  p p p pppp
3p pp pp

p
ppppp
pp

p
 pp
3p  pp p 
 p  
p
p  pp
3p pppp !p
p"p 

pp
3p 
Œppp ppp p pp
3p  p pp 
p 

 pp

DC
p
  p p p ppp

3p ppp 
#pp
p p pp
3p   pp
pp
p ppp p  pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
TC
p
* 
  p p p
p  p p pp p ppp pŒp p
 p pp
 p 
p  p p
  pp

3p Œppp
$p pp
3p  Œpp  pp  p pp
  p pp p p
p
p$pp
3p   pp

p p p
 p pppŒpp
3p p Œpp p
  p  p$p  pp pp
$p p p pp

ƒ    D     TRUNCTE, DEETE  DROP !"" # ±pp

p p pp


$ p
pp
p   p

DM !"" $ 


p
p  p #pp
$p ppp  pp  p p
p
ppp
pp p%  p %pp pp

p p $p p p
p 
pŒpp p

p pp 
ppp p p
$p p
pp
$pp

ppp pp 


 p pp pp

  p
   pp p ppppp
p p
p  p pp
p  p
p   pp pppp

p pp
pp$  p
ppp  p

  p
p  p
p  p
p p   p p ppp  p
 
   pp p ppp pppp  p
  p
pp
  p p p  
ppp pp  p

TCp
&
p
 $ pp
  p p p$pp p p pp pp p
p p ppp  p
p
'p   p
(pŒp

  pp  p
p
 $ pp
  p pp p
Œpp  p
p  pp
  p pp p
 pp pp p
$p pp
$pp p p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL )
PROGRAMMING
 p p $p
p 
p  p p p
p
 $pp
  pp
p
p

p pp  p

DCp
p 
p  pp  p
pp 
p p pppp 
p pp p
p p pp
p p pppp p
pp p
  p p ppp  p
p
'p p
(p   p

!p p
p  p   p  p
p
p

p p   p  pp!p p


p  p p

p p
  p pp
p  pp p  p  p
   ppΠpp ppp!p pp p
p

 p p!p
 pp!p  p  pp   p

3p p p
 p
pp
3p Πp p pp
pp
3p p p

p
pp
3p p p p p p p   p

p p  p  pp!p p  pp



p pp
p   p
p   pp p p pp pp
p  pp!p p
p
p
p pp p pp
p

 p pp!p
 pp!p  p  pp   p

3p  p p$pp p pp p


p
 p) 
pp
3p  p p 
p p p pp p
ppp
3p  p p  p  p p$ppp p p
  p pp p

p p 
p  pp!p p 
pp
p p

 p pp p
p
p pp  pp!p p
p p

p
p pp p pp
p 
 p pp!p
 pp
!p  p  pp   p

3p p p p p 


p p

p p$pp
3p p p  p p 
p
p

 p p$pp
3p   p p p
 p
  p
p   p
 p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p

   COMMND DET%

*  
     

ppà àp 3p
p
à p 3pp pà p 3
p
p
p
 &PUp p
p
p
p
ppppp pppppppppppppppppppppppp pppppppppppppppppppppp
p
ppppppppppppppppppppppppppppppppppppppppp
 p
p
ppppp   pppppppppppppppppppppppppppppppppppp 
p
p
ppppp pppppppppppppppppppppppppppppppppppp
p
ppppppppppppppppppppppppp ppppppppppppppppp p
p
pppp
ppppppppppppppppp ppppppppppppp p
p
pppppppppppppppppppppp pppppppppppppppppppp
p
pppp pppppppppppppppppppppppppppppppppppppppp p
p
pppp ppppppppppppppppppppppppppppppppppppppp
p
p
pppp
ppppppppppppppppppp

ppppppppppppppppp
p
p
pppp

pppppppppppppppppppppppppppppppppppppp
p
ppppppppppppppppppppppppp pppppppppppppppppp  p
p
pppp
pppppppppppppppppppp  ppppppppppppppppp  p
p
pppp ppppppppppppppppp
 ppppppppppppppp
p


p
p
pppp
p 


p
p
p
p
P' pp !"#p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
pppp ppppppppppp pppppppppppp
p
pppppppppppppppp pppppppppppp pp
p
pppp pppppppppppppppppppppp
 pp
p
pppp

pp
p
p
p
 p"#p
p
p
p
$p p%&' p(p')*)''p)&p$ p%+&() "p
p
p
p
pppp,pp-)))&p +.+p%&' p
p
pppp,pp)/.0)&p +.+p%&' p
p
pppp,p( %)&p&(&0p%&' p
p
pppp,p )&p&(&0p%&' p
p
pppp,p1 p&(&0p%&' p
p
p
p
 pp-)))&p +.+p%&' p)%0.'p$p-&00&2)+"p
p
p
p
pppp 
p 
pppppppppppp 
ppppppppppp
p
pppp 
p ppppppppppp 
pppppppppp
p 
p
p
pppp 
p ppppppppppp 
pp ppppp
p
  p
p
pppp 
p pppppppppppppp 
p pppppppppppp
p p
p
pppp 
p pppppppppppp 
p ppppppp
p p  p
p
pppp 
p

pppppppppp 
p

pppppppppp
p p
p
pppp 
p
 pppppppppppp 
p
ppppppppppppp
p p
p
pppp 
p

ppppppp 
p ppppppppppppp
p p
p
pppp 
p
 ppppppppppppppp 3pppppppppppppppp
p p p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppp 
p
  pppp pppppppppppppppppp
p

p
p
pppp
p
 ppppppppppp
p
 p
p
pppp
p
 pppppppppppppp
p
  pp
p
pppp
p
  ppp
pp
p
pppp
ppppppppppppp
pp
p
pppp
ppppppppppp
pp p
p
pppp
ppppppppppp
pp
p
pppp
pp pppppp
p p
p
pppp
pppppppppppp
p p
p
pppp
p ppppppppppppp
p

p
p
pppp
p pppppppp
p
p
p
pppp
p

ppppppppppp
p p
p
pppp
p
pppppppppppppp
p
p
pppp
p pppppppppppppp p
p
pppp
p 
ppppppppppppp
p
p
pppp
p p  ppppppp
 p
p
pppp
p pppppppppppp
p
p
pppp
p pppppppppppppppp
p
pppp
p

p
p
pppp
p
 p
p
p
p
 pp)/.0)&p +.+p%&' p)%0.'p$p-&00&2)+"p
p
p
p
pppp p
p
pppp  p p
p
pppp 
p
p
pppp  p p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
pppp p
p
p
p
 p( %)&p&(&0p%&' p)%0.'p$p-&00&2)+"p
p
p
p
pppp p
p
pppp
  p
p
pppp p
p
ppppp
 p
p
p
p
 p )&p&(&0p%&' p)%0.'p$p-&00&2)+"p
p
p
p
pppp 
p p
p
ppppp
 p
p
p
p
 p1 p&(&0p%&'p&01p&p%&'!"p
p
p
p
pppp 
pp

p
DpT pp3-!pppp
p
.;/
!p
pppppp$pp%ppp*+p p
/p9p
!p
ppp% pppp %ppp/::p
0p2p
!p
ppp pp p$p%ppp p
p12
!pp
pppp$pppppp p ppp
pp ppppp pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
:p !pppppp pp  <<pp
p
Data definition language (DDL):
p
9p!pppp ppp p ppp
p
 %!pp
p
p p 9pp=p>pp
p

= .>p= p >p4p5p
p= />p= p >p4p5p
pppppppp
pppppppp
pppppppp
= p>p= p >p4p5p?p
p
Column constraints :
p
.p # p@ !pp$pp$pp p pp p
ppp
/p 2p2p!pp$p$ppp pppp
0p A,!pp$pp$p pp ppp
p
1p 9&!pp$pppp ppp pp
 pppp
:p "
pp& !pp$pppp ppp
 pp pppp
Bp "p
p& !pp$pppppppp
pp p& pppp
Cp 'p p !pp$p pppppppp
p ppppp$pp  p
 p pp$p$&p pp p
p
Example 1!pp
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppppppppppp9ppp p$p ppp p& pp
 pppp p ppp/DDD(p ppppp
  ppp& p&pp pp
p

p
p
Example 2!ppp
p
ppppppppppppppppppppppppppp9p pp$p pp p& p p p
pppp
3->9pp p
pppppppppp
p
0p p& p
pppppppppppppp p/
.Dpp?p
p
Example 3!ppp9pppp
pppppppppp3->9pp9p
pppppppppppppppppppp
9E p
:p p& p
pppppppppppppppppppppFEp/
/Dppp
pppppppppppppppppppppp-Ep/
/Dppp
pppppppppppppppppppppp p/
1Dp
pppppppppppppppppppppp9 p/
/Dp
ppppppppppppppppppppppp/
/Dp
ppppppppppppppppppppppp#Ep
Gp,?p
p p
p-p9!pppp
ppppppppppppp pppppppp
$ppppppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
Example 4!pp9p(pp
p
p3->9pp#(p
pppppppppp
)E p
:p
ppppppppppp#(E p
:p
pppppppppppp# p
Hp
pppppppppppp# p&
)E #(E ?p
p
Create with Select!ppp
p
pppppp&pp pp%ppIp
ppp pp%pppppppp pp
pppp$ppp p
p
Example 1!pppppppppp
pppp3->9pp)p
pppppppppppppp pp)p)p pp) ?p
p
Create with select using where clause!ppp
p
pExample 2!pp9pppppp pp p.Dp p
p
pppppppppppppp3->9pp) p
pppppppppppppppppppppppppppp ppJpp) p
ppppppppppppppppppppppppppppppppIp K.D?p
Alter Statement!pppp pppp pppppp p
p
Syntax:
pppppppppppppppppppppppppppppppp
ppppppppppppppppp p=E>p
ppppppppppppppppp pppppppppppEpp E ppp=E>p
ppppppppppppppppp4   ppppppEppp E ppp=E>5?p
p
Add!ppp p$pp p$pp pp$ppppp
p
Example .!p p#ppp$p pp) pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
pppppppppppp3-> pp) p
pppppppppppp
#p
C?ppp
p
Example 2!pp ppp p& pp)pp
ppppppppppppppppppppp
pppppppppp3-> pp)p
ppppppppppppppppppp
# p&
?p
  !pppp ppppppppppp p
    p$pp pppIpppp
pppppppppp$p p$pp pp
 p
p
Example 1:
p
p   pp p p pppp
pppppppppppppp3-> pp)p
pppppppppppppppppppppppp  
p
G/?p
p
Droping the Constraints!p
ppExample1!pppp
ppppppppppppppppppp p# p& pp$ppppp
ppppppppp
pppp
ppppp3-> pp)p
ppppppppppppppppp p# p& ?p
Drop command!pppp pp ppp
p
Syntax:
ppppppppppppp p=E>?p
p
Example 1!pp ppp
ppppppppppppppp
p 3-> pp?p
p !ppp pp  ppppp pp
pp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
p
Data Manipulation Language (DML):
p
p !pp pp p$
p ppppppp
p
 p,p ppppppppppp
ppppp ppppp$p ppp
 ppppp2A--ppp p
Syntax:
ppppppppppppppp
=E>
E.LLL E?
p
p=E>
E.E0p
;
E. E0?p
p
Example 1!ppppp.DDp pp pp
p
pppppppppppp3->pp p
pppppppppppppppppppppppppp;
.DD+M+BDDD+.C D0+?p
Example 2!pp.D.p pp pp$p p p pp
'p(pppp
p
p3->pp p
ppppppppppp;
.D.+M+?ppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Example 3!ppp.DD.p pp pp$p pp
 pp
3->pp 
p
pppppppppp;
.DD.+M+?p
p$p!ppp pppp pppppp
p
 %!ppp
ppppppp=E>p
ppppppp= EE.>LL= EE>pp=E>p
pppppppI= >?p
Examplep.!ppp
p
pppppppppp3->ppp
ppppppppppppppppppppppp p
pppppppppppppppppppppIp K.D?p
p
p9 !ppp pp pp ppp pp
 %!pp
ppp p=E>p
pppI= >?p
Example 1!p pp p p.DD.p
p
3->p p p$ppKp.DD.?p
p
Example 2p!pp ppp ppp pp
p
3->p p ?p
p
Example 3!ppp pp p$pp$&pp&p
pppppppppppp
pppppppppppppppppppp3->p p p$p(pK+&+p
p
Update command!pp pp  pp pppp
p
Syntax:
A p=E>pp
p= E>pKp=>ppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p p
p p
p p
Ip= >p?p
p
Example1!pppppp p p p"p:DDp
3->p p ppKN:DD?p
p
Example2!ppOpppp/DPp p pp p:Pp
 p
3->p p pppKpJp./ppKp
JpDD:pN?p
p
Example3!pp#pppp ppp p
p
3->p p pp(pK+ p*p$p(Kp*+?p
p
Example4!ppOpppp.DPp p$p pppp"p
.DDDp
3->p p pppKpJ..p$pp=.DDD?p
p
Transaction control language(TCL);
p
p -pp$ppp p p ppp$p
p
p
.p pp $p
/p  pp
0p Ip$&p p3-pp -pp$pp
 p
p p -pp% p$p,pppp p$p
ppp&p ppp
p
9p !ppp pppppppppp
 p% p
p
3->ppp 
pppp
/DDp*+?p
3->pp?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
Roll back command!ppp pp ppppppp
p
p
3->p"&?p
p
Savepoint!ppp pppp&p pppp
p
Example:
p
p p p 3->ppLLLp
p p p 3->pp ?p
p p p 3->p pLLp
p p p 3->pp p
p p p 3->p pLp
p p p 3->ppp ?p
p 3->p"&?p
p 3->p?p
p 3->p"&pp ?
'p pp ppp&p$p
pppp
p
Autocommit command!ppp pp&pp -pppp
 ppp%ppp p
p
3->ppp?p
3->ppp?p
p
pppppp$pp$p p
3->p$p?p
p
Data Retrieval language(DRL);
p
p !ppp pppp pppp
p
 %!p
pppppppp=p EE.>ppLLpp= EE>pp=E>ppppppppppppppppppppp
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppppppppppppppppppp$p= >p?pp
)%p.!ppp  pp  p

p
p
p
)%p/!ppp  ppp p $pp$&pp
p
ppppppppp3->pJppp$p(*+?p
p
-p'!ppppp
p
´p  p
´p 'p
´p 2pppp
)%p.!pp  pp pp$pp$&pp pp
.Dp p ppp/DDDp
ppppppp3->pJppp
pppppppppppppppppppppppppppIp K.Dp p>/DDD?p
)%p/!ppp  pp pp$pp$&pp
p pp p/Dp
ppppp3->pJpppp
ppppppppppppppppppppppppppppppppIp(K++p p K/D?p
)%p0!ppp  pp pp$pp$&pp
p.D/Dp
ppppppppp3->pJppp
pppppppppppppIp K.Dpp K/D?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
)%p1!ppp  pp pp$pp$&pp
p pp p.Dpp$ppp p$pp
p ppp/DDDp pp p/Dp
p
ppppppp3->pJpppp
pppppppppppppppppppppppppIp(K++p p K.D?p
p
p'!pp
pppppppppppppppppppppppp
rp pp
rp p
rp $p
rp &p
p
^p p!pp pp&pppp p
ppp
p
)%p.!pp  pp pp$pppp p
p
pppppppppppppppppppppppp
pppppppppppppp3->pJppp
pppppppppppppppppppppppppIppp?p
^p $!ppIp$p$pppp ppppp
pp$ppp$pp
p
)%.!pp  pp pp$p ppp
p.DDDp ppp/DDDp
p
ppppppp3->pJpppp
ppppppppppppppppppppppIpp$p.DDDp p/DDD?p
)%p/!pp  pp pppp$pp$&p
p p.Dp$ppppppppppppp
*+ppp*(+p
p
p3->pJppp
ppppppppppppppIp K.Dp
p$p*)+p p*M+?p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
^p !ppIp ppp pp$p pppp
pp
 p$pppp
)%p.!pp  pp p p$pp$&ppp
&p p
ppppppppppppppp3->pJppp
pppppppppppppppppIp(p
*++&++ +?p
)%p/!p  pp p$pp$&ppp p
.D/D0Dp
pppp3->pJppp
ppppppppppppppppppppIp pp
.D/D0D?p
p
^p -&!ppp p$p p$pppp p ppp
ppp$p$p p$ p pp$pp
*P+p p*E+p
*P+pp ppp pppppp
*E+pp ppp pppppp
p
)%p.!pp  pp p p$ppp p$p
*+p
pppp3->pJppp
pppppppppppppppppppIpp&+P+?p
p
)%p/!pp  pp ppp p:pp
p3->pJppp
ppppppppppppppIpp&+EEEEE+?p
p
)%p0!pp  pp p p$ppp*+pp p
p p*+pppp
pppp3->pJppp
ppppppppppppppppIpp&+EP+?p
p
p
pp$p!ppp
p
)%.!pp  pp pp$ppp p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ppp3->pJpppp
ppppppppppppppppppppppIpppp?p
p
)%p/!p  p ppp$p$pp$&pp
p pp ppppp/DDDpp0DDDp
ppppp3->pJppp
pppppppppppppppppppppIp(K++p ppp$p/DDDp p0DDD?p
p
)%p0!p  pp p p$pp$&pp pp
p/D0Dp
ppppppp3->pJpppp
ppppppppppppIp ppp
/D0D?p
p
)%p1!p  pp p p$pp$&pp p
.D/Dppppp p$p*+p
ppppppppppppppppppp3->pJppp
pppppppppppppppppppppppppppIp p
.D/Dp ppp&p*P+?p
p

p
ppppppppppppppp
p
pp!pp p ppp p
ppppppppppppppppppppppppppp
3p 2pFp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
3p 9pFp
3p pp
3p Oppppppppppppppp
p
p
OpF!ppp
ppppp
.p 
%pppppppppppppppppp/pp
%pppppppppppppp0p
%p
ppppp1
Jpppppppppppppppppppppppp:pp %
%pppppppppppppBppp
%pppppppppp
p
.p 
%!ppp pp ppppppp p
 p
)%p.!pF ppppp pp pppp p
ppp
ppppppppppppppp3->p
pp?p
)%p/!pF pppp p pp ppp
 pp p.Dp
pppppppppppppppppppppp3->p
Nppp
ppppppppppppppppppppppppppppppppppppIp K.D?p
p
/p
%!pppp pp pppppppppppppppp
 p
)%!pF pppp pp ppp p
ppppppppppppppppp3->p
pp?p
p
09
J!ppp ppppp ppp$pppppppppppppppppp
 p ppp p
)%p.!p ppp p$&pppp
pppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppp3->p
Jpp?p
)%p/! ppp p$&ppp p&pp
pp
pppppppppppppppppp3->p
Jppp
pppppppppppppppppppppppppppppppppppppppppIp(p
*++&+?p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p1
%!pp ppppp p$ppp%ppp
 ppppppppppppppppppppppp pppppp$pppp
 p
)%p.!pF ppp p$ppppp
pppppppp3->p
pp?p
)%p/!pF ppp p$ppppp
 pp .D/Dp
ppppppppp3->p
ppp
pppppppppppppppppppppppppppppppppIp K.Dpp K/D?p
:%
%!pppp pp pp%pppp pp
ppppppppppppppppppppppppppp
)%p.!pF pp p$pp ppp p
ppppppppppppppppppp3->p%
pp?p
p
B
%!pp pp pppppp ppppppppppppppppppppp
p
)%!p pp p$pp ppp pp
pppppppppp3->p
pp?p
p
p
p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
2pF!ppp
p
rp 
p
rp ,
p
rp $
p
rp 
p
p
.
!ppp pp ppppp pp  pppp
ppppppppppppppppp pp
p
p 3->p
:pp ?p
p
/,
!pp pp pp,pppppp
ppppppppppppppppppp
ppppppppppppppppppp3->p,
0Bpp ?p
p
0$
!ppp pp ppppppp$ppp
p
p 3->p$
0/pp ?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
1
!ppp pp pp pp  pp pp
ppppppppppppppppppp3->p
:/pp ?p
p
p
p

pp p
p
96 " 9)"pFA29'2!ppp
ppppppppppppppppppppppppppppp
^p -
p
^p 9
./p
^p 
p
^p 
p
^p 9
p
p
p
.p 
!pp"pppppp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
ppppppppppppppppppppppppppppppp3->p
* +pp ?p
p
/p 
./!ppMp.p p/pppp$pp
p
pppppppppppppppppppppppppppppp3->p
*+++pp ?p
p
0p 
!pp"pppppppp
pppp
p
3->p
* +01pp ?p
p
pppp1p
!ppp"pppppp pp
p p p p
p p p 3->p
*+pp ?p
ppp
p:
!pp"pppppppp p
p
p p p 3->p
BHpp ?p
p
ppB$
!pp9ppppp$pp
p
p p p 3->p$
* +pp ?p
p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
Hp 
!pp9ppppppp
p
pppppppppppppp3->p
* +pp ?p
p
)pFA29'2!pppp
p
.p p
!pppp ppppppppp
  ppp p p
p
pppppppppppppppppppppp 3->p  pp ?p
p p p p3->p E
  0pp ?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
/p p$
. /!pp"pppp$p
p$p p  .pp%pp p /pp
ppppppppppp
p
p
3->pE$
+/GD0++/GD0+p
ppppppppppppppppppppppp ?p
p
0pp-p 
!ppp"ppp  pppp p pp ppppppppppppppppppppp
ppppppppppppppppppppppppppppppppp p
p
ppppppppppppppppppppppp3->pE 
  pp ?p
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

Op p!pppp pppppp pp p


ppppp$p$p$pp ppp
p
)%p.!ppp  pp p  pp ppp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p p p p
p p p 3->p 
ppp
ppppppppppppppppppppppppppppppppppppppppppOp p ?p
)%p/!ppp  pp +p$p p ppp
 ppp p
p
3->p %


Jpppppppppppppppppppppp
ppp p ?p
p
)%p0!ppp  ppp ppp
 pp p.D/Dp$pp p
p
p p p p 3->p 
pp
ppppppppppppppppppppppppppppppppppppppppppppppp)p$p K.Dpp K/Dp
pppppppppppppppppppppppppppppppppppppppppppppppOp p ?p

p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
6p9!ppp p$p$p$pppp pp pp
pppp p$p$pp
p
)%p.!ppp  pp pp$pppp pp
pp.DDDDp
p p p 3->p 
ppp
pp p p p Op p p
p p p p 6p
>.DDDD?p
p
)%p/!ppp  pp pp$ppp pp
$pp pppp.DDDDp pp p.D/Dp
p p p 3->p 
ppp
p p p p Ip pp
.D/Dp
pppppppppppppppppppppppppppppppppOp p p
p p p p p6p
>.DDDD?p
p
)%p0p!ppp  pp(+pp$ppp p
$&p  ppp p ppp(ppp
p0DDDpp$pppp p$&pppp0p
p p p 3->p(
Jppp
p p p p Ip pp
.D/D0Dp
p p p p Op p(p
p p p p 6p%
>/DDDp p
J>/?p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

' p p!pp p$p$p$pp  pp ppp p


 p
ppppppppppppppp.pp  p pQQp
p p
ppppppppppppppp/pp  pQ Q

Example 1: p  pp pppp p p


ppp
3->ppJppp
p p p p p ' p p?p

Example 2:pp  pp pppp  p


 ppp p
3->pJppp
ppppppppppppppppppppppppppppppppppp' p pp ?p

Example 3: p  pp pppp p p


pp   p pp p
3-> *  pp
p p p p ' p p p ?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
Example 4: p  pp pp$ppp p
 pp p.D/D0Dpp$pDp pp
$&pppp/p p  p ppp  p pp
p p

3->p 
ppp
p p p p Ip pp
.D/D0Dp
p p p p Op p p
p p p p 6p
J>/p
p p p p ' p p
p ?p
p

SET OPERATORS: p
p p
´p Ap
´p p
´p pp p p p p p p p
p p p p p

1. union!pp pp&p p$pppppp


 ppppp ppp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

Example 1: p  pp pp(+p.Dpp/Dp


ppppppppppppppp3->p(pppp
Ip K.Dp
Ap
p(ppp
Ip K/D?p
p
Example 2: p  pp(+ppp
p p pppp3->p(ppp
p p p pppppIp K.Dp
pppppppppppppppppppppppppppppppppApp
p p ppppppppppp p(ppp
pppppppppppppppppppppppppppppppppppppppIp K/D?p
p
/intersect!ppp pp&p $ppppp
p
Example 1: p  pp(+pp p.Dp p/Dp
p p 3->p(ppp
p p p Ip K.Dp
p p p p
p p p p(ppp
p p p Ip K/D?p
p
Example 2:p  pp(+pp p.Dp p
/Dpp0Dp
p p p 3->p(ppp
p p p p Ip K.Dp
p p p p p
p p p p
p(ppp
p p p p Ip K/Dp
p p p p Ap
p p p p p(ppp
p p p p Ip K0D?p

2. minus: p pppp$pppppp


p$ppppp pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

pppppExample 1: p  pp(+pp .Dp ppp/Dp


p p p p 3->p(ppp
p p p p p Ip K.Dp
p p p p p p
p p p p p p(ppp
p p p p p Ip K/D?p
Example 2: ppp(p$pp,pp p.Dpppp/Dp
 p0Dp
p p p p 3->
p(ppp
p p p p p Ip K/Dp
p p p p p Ap
p p p p p p(ppp
p p p p p Ip K0Dp
p p p p p p
p p p p p
p(ppp
p p p p p Ip K.D?p p p p p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
SUB QUERIES(or)NESTED QUERIES:pp$p$pppppp
ppppppp$p$ppppp
p, p, ppppp$pp% pp p p
pp ppppp
p
Syntax: pppp
p p pppppF=p>p
p p pppppI
p?p
p
Example 1:pp  ppp +pp$p pp
pp+p p
p
p p p 3->pJpppp
p p p p pppIp>
ppppp
p p p p p p p IpK+ 6+?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p
Example 2:pp  ppp +pp$pppp
p p
p p p 3->pJpp p
p p p p IpK
p%
pp?p
p
Example 3:ppp  ppp +pp$p(ppp
&pppppp ppp p
p
p p p 3->pJppp
Ip(K
p(ppp$p
K+ 6+p
 p>
pppp
IpK+ --)2+?p
p
Example 4:p  ppp +pp$ppp
 pppp pppp +p
p
p p p p 3->pJppp
p p p p p Ip>
p
pp?p
p
Example 5:p  pppp$ppp +p
$&p pp pp%pp p p$p
ppp
p
p p 3->p
Jppp
pppppppppppppp p Op pp
p p p 6p
JK
p%

Jpp
p p p )pp p?p
p p p p p
Example 6:pp  pp pp p$p%p
p +p$&p
p
p p 3->pJppp
p p p p IpK
pppp
p p p p p p p Op pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
6p
JK
p%

Jpp
pp p?p
p
Example 7: p  ppp +pp$pppp
 pp p
p
p p p 3->pJpppp
p p p p IpK
p%
ppp$p
p p p p p p =
p%
pp?p
Ipp, pppppppppp p
$pppppp pp
p
Example 8: p  pp pp$p ppp
ppp ppp p/Dp
p
p p 3->pJppp
p p p Ip>
pppp
p p p p p p Ip K/D?p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
Views: ;$ppp  ppppppp +p%p p
p pppppp  ppp$pp$pp
 pp  ppp$p$pp pp ppp
ppp$pppp p p pp ppp
$pppp$ ppppp
p
Advantages of views: p
p
^p # pp pppp
^p pp ppp ppppp
^p 9 p,ppp p pppp$ppp
ppp
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Creation of view:ppp
p
Syntax:pppppppppp$p=$p>p
pppppppppppppppppppppp pppp=p>?p
p
Example 1:pppp$pppp$p p
p
p p p p 3->p$p$p
p p p p p pppp?p
p
Example 2:pppp$ppppp p.Dp
p
p p p p 3->p$p .D$p
p p p p p ppJppp
p p p p p p Ip K.D?p
p
p
Insert into view:

Example 1: pp$p pp$p$p


p
p p 3->pp$p
p p p ;
.D.+I-- +/DDD?p
p
Viewing the contents of d10view: p
p
Example: p  pppp .D$p
p
p p p 3->pJpp .D$?p
p
p
p
p
p
p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
p
Replace: "ppp p$p p$ppp$pp
%ppp$p$ppp

Example: pp$p$p p pp p


p
p p 3->p$p$pp
p p p pp pp?p

With check option: Ipp p$pppppppp


 p$pp pp$p ppp$pp$pp
$p&pp
p
Syntax: p$p=$p>p
pppppppppppppppp pp=p>p
ppppppppppppppppIp= >p
pppppppppppppppppIp&p?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Example :  p$pp p pp p/Dp
p
p p 3->p$p /D$p
p p p ppJppp
p p p Ip K/Dp
p p p Ip&p?p
p p ppp ppp/Dp$ppp ppp$p
p
Sequences: Ip p$pppp(p$pppp
pppppp p
ppp$p$pp
pp,p
p
Syntax: p,p=,2>p
pppppppppppppppppppp$p=>p
p p p p=>p
p p %p=>p
p p p=>p
p p 9p
p p 9 ?p
Ip p$pppp%pppp,pp$p
$ppp%pp p$p p$pppppppp
,p$ppppp
p
Example: p3->p,pp
ppppppppppppppppppppppppppppppp$p:p
p p p pppp p.p
p p p ppp p:p
p p p ppp %p.:p
p p p ppp9p:p
p p p ppp9 ?p
pppppp,p$pppp$p
:p p.ppp:%ppp.:pp:p
 p$p p
p
Altering the sequence: $p p$ppp pp p
p
p%p,pp$p$ppp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Note:p$ppp pp p
p
Syntax: p,p=,> p
p =ppp >?p
Example!pppp3->p,pp
pppppppppppppppppppppp p/p
ppppppppppppppppppppp p.Dp
pppppppppppppppppppppp %p.DD?p
p
Drop sequence: Ip p$ppp pp,p$pp p
p
Syntax: p,p=,>p

Example: 3-> p,p?p


p
INDEX: Ip pppp pp ppp
 pp$p$ppp %pp
p p ppp %  pp p$p$pp
p ppp$ppp %ppp   p %p
$ppppp:DDp pppppp
p p pp0p pp %pp %pA,p %p
 p9 p %p
Syntax: 3->p %p= %p>pp=p>
= p
>?p
p
1. Simple index: p p$p % p ppppppp
p

Example 1:pp3->p %p pp


?p
Example 2:pp3->p %ppp
!p
p
2. Unique index: p p$p %pp ppp
,ppp$p %p

Example : 3->p,p %ppp


?p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
3. concatenated index: p p$p %pp pppp
ppppp
p
Example: 3->p %p pp
?p
p
Delete index: ppp

Example: 3-> p %p ?p


p
p
p

âhat Is The Difference Between SQL and PL/SQL?


.& 
#)
"$ &   &      %&   Îc 
&  ! & 
!#+!
 &

 %
"$
$/"$Î$.0

âhat is SQL?

"$

1  !2ÿ 
    " #$
 Î3 &"$ # 
)%
 !! 
 
$
 $

 !  !! 
 ! 

$
  $Î!! &
)4 
#%#  # & % &"$  & 

 &
)%
!  
 & 
 Î.&! & !  

DDL or View

$-.56*!# 

7%!! & 
 &!# 
!

DML or Manipulate

,.!# .!#
 89&
:3c!# ’

6
 &!#'’
&
 & 
 9&


âhat is PL/SQL?

.&!
%  &$/"$, ; 
$/"$ *!:  !+ 

"$  
)
  &
 


!
 ;$ÿÎ'    %


   &  
 ! 
)!
 


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
!! 
 # + 


 
&
Î$/"$!     #


)!
 & & & 
 
% &"$
 &*! 
 Î
c &<.&  %& ' & &   &



Î  &&!)! !! & 
  &  

!! & &
  &  !"$
 
!     !


 !(

!
 -== 9)  Îÿ6

 # 
 ! 
'ÎÎÎ.&

 

# $/"$  
 ÿÎ

c 
 
$/"$$% -


&
*! 
 + ÿ

1''%
  #%
)# & 
 
$/"$ % !
 & $/"$  &
*!
 )
!
  & )  
 
! 
)!
Î' 


 )!#!!  "$
)  ! ! & !!
#
"$Î

DIFFER
"$  
!
  ! 


 ! 
   Î$/"$ 
 !!
   ! 
Î  
: 
!!#&)1"$! 
2Î  

!!#&)
! 
 &   "$
! 
! 
 
 &
(
Î$/"$


 &! 
!
 4 !(9)c
Î"$#
 &   
#  
%
 
 Î$/"$& 
 &!
 #   
!  

 !# &  
%
 
 Î

What Is Dynamic SQL?


 $/"$    
!4
Î6+!   & 
 
!#


 !#
   &
   &! 

 &  
!Î'

&    & !! +  &  
 (
%
 ! Î &  

 
&
+ 
 + 
Î  &#!!£  "$  
Î

c%)    
!
 ) #"$  
 
 Î6
+! 
!   %  
!
   
 &) 
  
  Î'
 &    & !! +  &  
 
(
%

!
 Î &
 




!#%!! &
+ 
 + 
Î  &#!!
u "$  
Î

#
"$  
 
&  
 
! 
##  
 Î &

  

 & + )!"$  
$/"$
!(Î.&#
! 


!&! 

 
Î u
 

!
   
  %&&
#  +!
 
  Î6+! $/"$( 
 
 

 %

&!!%
 
 


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
öp p pppp !pp 3p"p ! 3öp
öp p pppppp 3p"p öp
p

.  #


"$  
#   &# $ $  
Îc%) 
  ! % #   
ÿ #    & %    
  
 
Î

   ORÿ

p3-ppp%  ppp
  p3-pp$ppp
p p3-pp p
$pppppp3-ppp
&$ppp
Rp)S)9A)p )  )p
Rp#")# ")p p)S)9A)p
Rp# ppp ppppp
)S)9A)8F)96pp

The Need for Dynamic SQL


 
#
"$
 &!!%
   


´p  %
 + "$ 
 
  
 &  ÿ  
!
 
 & &ÿ   

!  
 & $ ÿÎ'

$/"$  &  


 
+   !!#Î
´p  %
!+
! #Î6+! # & %
 # & &

4 
!
 Î* # & %
#  
!
 &

 
 &!    
Î!+& 
& ) "$ 
!   Î
´p   (' !( + "$  
#
!!# 
# %

 

   &
    
 
! # & ' !(!(  & 
 
4 
!! 
Î

ORÿ

p3-!p

 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ü pStatic SQL
!!!%
   & 
  
 &

!
 )"$  
% &

 

   Î
!.& 
 
   +



8&:
 &Î
ü pDynamic SQL
!.&
#   
%& &
 
 
   
 +

 (
%

!# 


p
ppp p$pp$p pp
  p3-ppp3-p pp$pp
ppp ppppppp
pp
RpFp%ppp3-p$ppp$!p
Rp)S)9p3-p )O2p )9- ")p)9'2p
p24/D5?p
)S)9p3-p)2 p )9- ")p)9'2?p
)S)9p3-p2)"p2'p!2p
; -A)p
T.UpTUp/1p
Rp)S)9p3-p )9- ")p.p9A"'"pF'"p
)-)9pJpF"' p!2p

p#p
RpTJUp ppppppp
2pppppp$p
 p$ppppp
Rp p pppp$p p$p
p
Rp pp$p pp&$ppp p p
 p$ppppF)96pp
p p3-ppppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
 p$ppp$pp
p  p

The EXECUTE IMMEDIATE


Statement:
ü For example,
Static SQL:
>-"$;'-$-.'*
! 

?
>-"$-$-.'*
>-"$,. . !# !#=


3c  1$2
#
"$
>-"$;'-$-.'*?
&
@’’ ?
>-"$-$-.'*?


 1,. . !#  !#=A
3c  8$:2 

ÿ?
>-"$>-,.''.
?

Examples of Dynamic SQL for Records, Objects, and Collections

  &!!%
+! &% # 
 &%  & !   #
 ! %
#


 p
ppp)p *+ p$pp  ,p
ppp ! -ppp *+ ,p
ppp !+ pp . ),p
ppp/!p0 121445,p
ppp !637ppp0 12895ppö :ö,p
'&$p
ppp/!ppö p;p p pp637pp6ö,p
ppp p ! -p p/!p$&p !637,p
ppp p
pppppp p ! -p$ p !+ ,p
pppppp#$pp ! -.  ,p
pppppp%%p+3 p+ 3+p
pppp ,p
ppp  p ! -,p
,p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
.&
+ +!!!    & 
4 
!! 
Î  # 

4  #
 +3
0) #377<   !!% 

p)p +3pp '= p2 p0 12195p> p '5,p


p)p377< p$p0)2845p p0 12195,p
p
p
p

Embedded SQL 


)  p3-pp
'p  pp  ppp p9p
9' '-pFp#p#-8.p

Types of embedded SQL:
!  
"$ %& &

"$  
 (
%
%&
 &
 % 

!#

"$ %&&!!% 
!!  &"$  
 

 

!#
"$) 
 
!+
! #
&!  

!    %

Simple Embedded SQL Statements
ü pp pp  p3-pp
ppp pp p p, p
p
Rp2pp2)"pA# )p
)-))p9") )p -)p


Some comments for the example
)  p3-ppp$p
& $ p)S)9p3-p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p)  p3-pp p$pp
p+p  pppp
Rp9p#-8.p pU?Up
Rp9' '-pp)2 )S)9p
p p  p3-pppp
 $ppp%ppp
ppp
p  ppppp3-p

Processing Programs with Embedded SQL:-







Embedded SQL Application

 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Running:-
p
p
p
p
p
p

p
p
p
p
Retrieving data Using Embedded SQL
p p)  p3-p  p,pp$p
!p
Rp$p,p$pp, pp
pppp$pp p
Rp $p,p$pp, pp p
pp ppp$p$p
 ppppp
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppppppppppppppppppp

P'  Procedural Language using sql)pppppppppppppp


p
#-83-ppp pp%pp3-p$ppppppp
3-ppp$pppp$p$ppppp
# p-p
p p p p p
'"p
#-83-pp'Vp# p-p
%pp3-p
p#-83-pp pp
pp
p#pp$pp#-83-ppp
 pp pp
p#-83-p ppppp
p ppp'p
p#-83-p ppp -p p 9-.p
p
PL/SQL Block
p#-83-p&pp p
 p3-p p#-83-pp
pppp p#-83-p&!p
p p
!p p
 p
p pp
p%p
, !p%p3-p p
#-83-pp
%p
!ppp
 p
p
)%p#-83-p#p
pppppp!p.,p
p)%pppp3-J#p
3->pp.p
p)pppp!p
3->pppp
ppppppp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ppp#-83-pp
p
p
p
p
p
p p p p p
'"p
p
p'p!p

3&
 

 &$/"$

 
! 
)!
 !
 $/"$

!( 

 Î.& !   &
!(   !!$/"$

Î.&


+  !! !  
  &! 
  
 
 
!#"$  
 
*!Î.&   &%( 
  &! 
   
   & )  Î

6  &  &


!(


"$  
 &

+   &

!(  &
! 
  Î.&    !# ! 



 
 
!
  )

!Î

6 
!# *!6 ! 
 "$  
!#    &)! !

   !  
Î# 
$/"$
 # 
)!!   &*!
)Î) # 
 $/"$
 
 
 ! !
 Î

Advantages of PL/SQL

$/"$ ! !# 


! &&
 
 
 
!
  &  
&!!%
)
 

´p   "$
´p   
4 


´p  

´p c&  ) #
´p 6 !! 
! #
´p .& 
 
% &*!
´p .&    #


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
Understanding the Main Features of PL/SQL

%#   


% &$/"$  !(  !Î.&
!%
  
 

 ( Î6  ! )


! # '   &

 # 

 ( 
&
Î.&
  )  & 
 #
&
 
  
!

<- 3+ Î' & 
 #   &
  &    & 
!

 
 & 

 & 
!
*+  !+ 3+Î* &%   &
 

  (
 &*+  !+ 3+ 
!

3 &$/"$ # 


 "$  
 
 ! *! 
!%
!
 
   & Î  
! !


)
! 
  


 

 
 Î.& $/"$

  & 
 ! 
%
"$% & &  
% !!
  Î

Block Structure

$/"$ b  £

u!
 Î.&   &
 
   
 




# 
!( ÿ & ( $/"$!!
!( %&&



#



 

!( Î.#!!# &!!
!( 
  
!


! 
 !)Î.& $/"$   &)

& 
!
!)
!!£ £
 Î


!(

!(ÿ! #  !!!#! ! 

  
Î.& %# 
# 
!! 
!  %& &# Î.&! 
!!  &
!(

  + %&
 &
!(!  Î

.&!!%
6';, &% $/"$
!(&  & ! ) 
+ 
!
 

+ 
&
!
 Î'
$/"$ %


 
 !!

  Îÿ*
!# &+ 
!   Î


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
.& &  !!Î6   &! ) 
%&&  

!Î
*
!   


 ! 
 &+ 
! Î+ 
  

+ 


! % &
 &+ 
&
!
 Î

Variables and Constants

$/"$! # !




)
!  &
  &
"$
 !
 

#%&
+ 


 Îc%) %
 
 !!%Î
 #  !

)
!b


 
 &  

! 

 &! )  
Î

  
 p

7
! 
&)
#"$  #  &     ' 
#$/"$  # 
& ' '$)!$&Î6+!   & # %
 !)
!

+!3 &! 

 
)
!
<!3 ? &! &!

)! Î  ! & )
!  !!% 

+!3pp '2@5,p
<!3 ?p' ,p
p

 
! !
  
! )
! # )#  & ÿ 
  
 &
' 0) 
     # Î

|     


 p

 
 
)!   )
!
 &%# Î.& %#   & 

 
ÿ !
!!%
#
 ! 
Î  ! &)
!  &!  & 


+ 
%&&

! 
 
!! ÿ  && Î%+! !!%

App+< p;pA!+ ,p
-<!<pp,p
73*pp *++ !+ p;p4
84,p
B> pp>+3! 2 !<p!+p3!+5p%p * <3,p
p

.& 
%#  
)!   )
! 
# ! 
 &
ÿ 
 )!  
 Î
'
 &+!
!% # &)*! ’A

%&
#  !  & !#

!#Î% # 
  &)
!73*

 &  

  )! 

 
  
!Î

 pp;p4
84p$ p73*p p pp 3pp !<,p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
.& &%#  
)!   )
! 
# 
  
 $   

Î  &!!%
+! &% 
$  ! #  
 !)!   
&


!!
 
  )!    &!!

 p
ppp !p2C15,p
ppp p6*!+ p2 !<p$p+ p$p p5p$p

p
'&$p
ppp p0&25p$ p !p p ,p
ppp6*!+ 2CCDDp !5,p%%p<>pp Bp-* p3p !p

   p

!


 !(!
)
!+  & #   &(#% 

 !# 
)!   &

Î.&  
 

  &


!!%Î'
 &!!%
+! # !


 + <!<<

+ <!<<p ppp9444
44,p
p
p
p
ppppp$p !p
p
#-83-pp   pp0pp
. p!p ppp
p/)%p!pp ppp&pppppppppppppp
p$ppp
0)%p!p)pppp  p p
p
DBMS output.put line(string): ppp ppppp
pppppppp
p p p 3->pp?p
Rtype:ppp pp p$p$p$ppppp
 p pppppppp
p
Example: pP ?8Jpppp Wppppp p
ppJ8p
p
Syntax: p
p p p ppp!pppppppppppp8J p&J8p
p p p ppp p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ppppppppppppppppppppp pppp!pppppppppp8J)%p&J8p
p p p ppp)%p
p p p pppp!pppppppppp8J)%p&J8p
p p p pppp) ?p
p
Example: pIpp#-83-p&p$p ppppp
p
3-> pp
pppppppppp p
ppppppppppppp"p
/!K.D?p
p pppp#pp
10!K0.1?p
p pppp p
C/?p
p p
p p !K#J"J"?p
p p EE
*pK+QQE
?p
p p ) ?p
8p
3->X?ppp8Jpp%pp#-83-p&J8p
p
p p ppp-  -

 

p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

pppppppppppppppppppppppppppp p

PL/SQL Datatypes
)#

)
! 
 & u   ÿ %&&   
 


)!
)!  Î$/"$) ) #

  # Î6

 # 
& 
 ! 

&  !
  
!! 

 
$* # Î'
 
$/"$! # 
# %

# Î

Predefined Datatypes
£
 #& 


!

Î  £  #& 

!

 & 



 ! 
) !!#Î

 #&! )!  !!  
£  &  
  &
  Î ' #&! )!  !!!
!   &  # &! 
!

4 & +!ÿ  !
Î
Number Types
 
 # ! #  
 
 !

 
! 



 ÿ 
 
 
  
! ! 
Î
BINARY_INTEGER
   &'$)!$&  #   

 Î' 
 
 55ÎÎ
55Î$(!$&)!  '$)!$&)!   !   &
 '
)!  Îc%)  '$)!$& 
 !% &
!$& 
Î
BINARY_INT EGER Subtypes


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
b£   &  #%&&
# )Σ b    
  #
% &


 
 
 )!  Î6# 
)

 $/"$
  &
!!%
'$)!$&
# 


 $$0
 $$0
$&)
p
NUMBER
.& #
+!!% 
 'E2+ <<3  5Fp
p
.!+


 %&&#   #£   &!!%

 '2+ <<3  5p
p
NUMBER Subtypes
 
  &!!%
 '
#  
! #% &'/'*
' # 
%&
# %
  )

 
 $ 
 ' $$ 
 
$&
$
 $ 

 $
p
PLS_INTEGER
   &!$&  #   

 Î' 
 
 55ÎÎ
55Î!$&)!   !   &
 ')!  Î
Character Types
-&  # ! #  !&
   
% 
 + 

 ! 
&  
 Î
CHAR
   &   #  +!
 &&  Î
.& #
+!!% 
E2A<*!<G pE pHp')Fp5Fp
p
CHAR Subtype
.& 
#  &  & 
)!    
  #Î
LONG and LONG RAW
   & &  #  )
!!
 &&  
 Î.& &  # !(
&0 1  # +  &  &+   &)!   ’
#  Î


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
   & &  #  

# 
#  
 Î &  !( &
  +  &  &  
 
 
#$/"$Î.&+   &
)!   ’
#  Î
RAW
   &  #  

# 
#  
 Î
 &Î
.&  # (    & ! #  #+     

#  Î.& #
+!!% 
2A<*!<G 5p
p
ROWID and UROWID
'

!!# )# 
  
!&  $  ! 
%&&  

#)!  !!
rowidsÎ&% 
 &  %Îphysical rowid
 %



# 
!Îlogical rowid
 %


+
 
!Î
Physical Rowids
(p p+3B<p  p p pp 3ppCCDD,pp
p
&  
 &!!%
%
 $pppppppppppppp p
%%%%%%%%%%%%%%%%%%p%%%%%%%%%%p
/ 'p p
p
Logical Rowids
$!% ) &      !% ÎÎ
VARCHAR2
.& #
+!!% 
0 12A<*!<G pE pHp')F5p
p
VARCHAR2 Subtypes
.&0 1
# 
!%&) & 
)!    &
  #Î6+! 
0  4 
 &
0 1Î
$&
0 
$0! $Î


-  
 


The PL/SQL compilation and run-time system is an engine that compiles and executes PL/SQL blocks and
subprograms. The engine can be installed in an Oracle server or in an application development tool such
as Oracle Forms.

In either environment, the PL/SQL engine accepts as input any valid PL/SQL block or subprogram. Figure
shows the PL/SQL engine processing an anonymous block. The PL/SQL engine executes procedural
statements but sends SQL statements to the SQL engine in the Oracle database.

-   


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )


 

THE PL/SQL ENGINE(Processing)

//****>
THE PL/SQL ENGINE(Processing)==//
p
p
p
p
TRIGGER: pp ppp ppp pp
pp pp p p p$ppp
  ppp$ppppp
 p ppp ppp%ppp
#83-p&p$pp2)"=A# )p )-))pppp
p$p
p p p ppppppppppppppp
'"p
p
!p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppp p&pp
#-83-p p
p pp ppppppp
pppp ppp%pp
ppp pp pppp
p ppp
%pp$p
ppp
ppppppp
 pp ppp

p
p
p
p
Advantages of Triggers:
p
´p  p9%p pp


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
´p  p
´p  p
p
Syntax: 9pppp=p>p
p ppppppp 8ppp pp pp=p>ppp
$p
p p p
ppppppppppppppppppppppppppppppppppppp!p
ppppppppppppppppppppppppppppppppppppp!p
p p ) ?p
p
Example 1:p9ppp pp pppp$p
pppp$pppppp +p ppp
:DDDp
p
3-> p.p
p p 9ppppp
p p pppppp$p
p p p
p p !$>:DDDpp
p p p "EE
/DDD.+ pp:DDD+?p
p p ) p?p
p ) ?p
8p
p
3->X.p
p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
p
p
Example 2: p9pp ppp pp$ppp
pp pp pp pp$ppp ppp
 p$pp%pppp
ppppp p
 +pppp p
p
3-> p/p
p p 9pppp p
p p p pp pp ppp$p
p
p
2p
1?p
p pp pp
p p
Jpppp
p p Ip K!$ ?p
p
>.pp
p p "EE
/DDD.+" p%p
pp+?p
) p?p
) p?p
) ?p
8p
p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
3->Xp/p
p p p p
ORp

T (( )
p!p ppp ppp
 ppppp p
p
pp!p
p
pp)p
ppp
pp9 p
p$ppp pp
pp p
$pppppp
p
!p)%pp
9") )p"OO)"p A p
F)"p2)"p'2p -'"p
")F)")292Op2)Ip -)p2$p
F'"p) 96p ) )2p
2)"p
2'p<
 pppp
)-)9p pppp
F"' p2$p2p
I6)")p2p=Kp.Hp
(OR)

*  p p p 


 p 
p p p pppppp  pp
* p
p ppppppp pp p p
pp
p
p p p  pp pp p pp pp p
p p ppp

pp  p p 
 p pp p
ppp
p pp p
 
p

*  p p
pp p p p pp p  p p   p p
p
   p*  p pp p p  pp p  p p !" p*  #p
*  p
pp
p  p p p$p

CREATE TRIGGER trigger_name


ON { table | view }
[ WITH ENCRYPTION ]
{
{ { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] }


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS
[ { IF UPDATE ( column )
[ { AND | OR } UPDATE ( column ) ]
[«n]
| IF ( COLUMNS_UPDATED ( ) { bitwise_operator } updated_bitmask )
{ comparison_operator } column_bitmask [ « n ]
}]
sql_statement [ « n ]
}
}
p
*  p p p pp  $p%*&pp"'(*)p+%p p  p%*&p*&",,&(p
 p p ppp
p  pp pp p p"p ppp
  pppp p  p p
p
pp p
pp  pp p
 p pp pp p  p%*&p*&",,&(p
pp 
pp p
p
pp pp p pppp ppppp
 p

pp  
ppp p  p%*&p*&",,&(p

 p  p%*&p*&",,&(p


pppp-.pp pp
pp
p

ppp-.pp

"pp"'(*)p+%p  pp pp p p


p/  p
"pp"'(*)p+%p  p0'p
pp pp p* ppp p 
pp
 p
pp pp"pp"'(*)p+%p  p  ppp p
p pp
"pp"'(*)p+%p  p  pp

p

p p p

C ! 
*!  %(  + "$  

  

 
Î$/"$

  !!
£
! # 
%(
   
 
Î.&
%(
     
 Î$/"$! !#!   !!"$ 

 ! 
  

! 
   &  

!#
%Î6   &  

&

% # 
+! !#!     &% 
) !!#Î
+!
!!% 

 p
ppp  p 8p$p
pppppp p 3p  p637p p pp 3pp14,p
p


p p

C !  P' 
2
5p

pp

 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p9 pp3-p, pp
p$p
6$ppppppp, Yp
pppppp p
Rp2p p$ pppppppp
Rppp ppppp p  p
 p
p$!pppp3-p
p
pp!p
pEpp
E?p
)%!pp.pp
p pp p
p?p
p, p ppppp
% ppp p
! (  C !
p pE?p
p pEp
p p EE?p
p pE?p
'ppp, p pp
ppp% p
Cursor FOR Loops

'
    
 &  
+!    # 
 !#

# 
   
!
 &    
    
Î   !! !#!  
!
+  &  
% & & 
 Î+  
   
 !# & % )!   & !   
! 
 &  &
!   &
  %&
!!% &)

 Î'
 &!!%
+!  &   !
! !#!  !+  

 p
ppp  p 8p$p
pppppp p  pp<+  p 3p p ,p
ppp

p
'&$p
ppp p !+ p$p 8p p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
pppppp

p
pppppp+ !3ppp+ !3pIp !+
,p
pppp ,p
p

.

) !! 
 & #  u     
%&& 
ÿ )   &


 ! Î

Cursor Variables

$(     )


!
  & 
%
 & !    ! % #Î
 
!(     )
!



# # 
! #Î'  
  
  #Î-  )
!   $/"$)
!  %&&# 
 

%
)!  
%&&# 
  
  

*! 
 Î.& ) # 
!+
! #

)

%# 
!  )!Î

.#!!# # 


  )
!
# 
     & !   
)
! 
 !  Î.&!!%
 
 &  )
!
>  +< ! - && 
 #

 p3 ! -p2>  +< ! -p$p p&  +< *+  3< p '5p$p
'&$p
ppp$p 3< pp8pp
pppppp p>  +< ! -p p p;p p ,p
ppp$p 3< pp1pp
pppppp p>  +< ! -p p p;p p ,p
ppp$p 3< ppJpp
pppppp p>  +< ! -p p p;p p>+ ,p
pppp$,p
ppp

p
,p
p
p
p
p
p
p
p
/*PL/SQL program for checking if a number is prime or not*/

3-> p,p
p p
p p 2p!KW?p
p p p!K/?p


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
p p "p
0!KD?p
p
p I
=K8/p
-p
p "!K
?p
pKDpp
p p )%?p
) p?p
p !Kp
.?p
) p?p
p pK.pp
EE
*+?p
p
p EE
*p+?p
 p?p
 ?p
8p
p
3->Xp?p
p
OUTPUT:


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

PROGRM---üÔ)

* +9: *:  *";+!: 


 "* <+!:  *=!"++>


For inserting the values:-


SQL> insert into sb_account values(&acc_no,'&cust_name',&bal_amount);
Enter value for acc_no: 111
Enter value for cust_name: SHAIK ABDUL QADER
Enter value for bal_amount: 17000
old 1: insert into bank values(&acc_no,'&cust_name',&bal_amount)
new 1: insert into sb_account values(123456,'SHAIK ABDUL QADER',15000)
1 row created.


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

SIMILARLY,create some 5 to10 rows.

P'  CODE:-
declare
2 ano number(10);
3 cn varchar2(35);
4 ba number(10);
5 re number(10) :=1000;
6 dep number(10);
7 wit number(10);
8 msg varchar2(50);
9 d3 varchar2(50);
10 begin
11 ano :=&accountno;
12 select acc_no,cust_name,bal_amount into ano,cn,ba from sb_account where
acc_no=ano;


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
13 dep :=&enter_for_deposit;
14 update sb_account set bal_amount=dep where acc_no=ano;
15 if re < dep
16 then
17 wit :=&withdraw;
18 dep := dep-wit;
19 if dep < 1000
20 then
21 d3 :='your account doesnot have suffisient bal';
22 else
23 update sb_account set bal_amount=dep where acc_no=ano;
24 d3 :='your transaction has sucessfully completed';
25 end if;
26 else
27 msg :='YOU CANNOT âITHDRAâN DUE TO INSUFFICIENT BALANCE';
28 end if;
29 dbms_output.put_line(d3);
30* end;



d?





 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

 

PROGRM---ü)

AbdulQader(SQL)>CREATE TABLE COLLEGE_INFO(COLLEGE_CODE


NUMBER(5)PRIMARY KEY,COLLEGE_NAME
VARCHAR2(20),ADDRESS VARCHAR2(25));

Table created.

AbdulQader(SQL)>CREATE TABLE FACULTY_INFO(COLLEGE_CODE


NUMBER(5)REFERENCES
COLLEGE_INFO(COLLEGE_CODE),FACULTY_CODE
NUMBER(5),FACULTY_NAME VARCHAR2(25),QUALIFICATION


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
VARCHAR2(10),EXP_IN_NO_YEARS NUMBER(5,2),ADDRESS
VARCHAR2(25));

Table created.

(A)

ACCEPTING THE DATA FROM A FORM:-

(B) GENERATE THE QUERE FROM SQL MODE:-


(i)pSELECT FACULTY_NAME ,
EXP_IN_NO_YEARS,QUALIFICATION FROM FACULTY_INFO WHERE
EXP_IN_NO_YEARS>=10 AND QUALIFICATION='MTECH';


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(ii)pSELECT FACULTY_NAME,EXP_IN_NO_YEARS,QUALIFICATION
FROM FACULTY_INFO WHERE EXP_IN_NO_YEARS>=10 AND
QUALIFICATION!='MTECH';


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

PROGRM---ü)

AbdulQader(SQL)>pCREATE TABLE LIBRARY(BOOK_NO


NUMBER(5)PRIMARY KEY,TITLE VARCHAR2(20),PUBLISHED
NUMBER(5),AUTHOR VARCHAR2(20),STATUS VARCHAR2(20));

Table created.

TRIGGER:-
AbdulQader(SQL)> create or replace trigger LIBtrigger before INSERT OR DELETE OR
UPDATE on LIBRARY for each row
declare
sta varchar2(25);
pub number(5);
begin
select published,status into pub,sta from library where published>1;
if pub>=20 then


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
sta :='cannot be issued';
insert into LIBRARY value('sta') âHERE PUBLISHED>=20;
end if;
if pub<20
then
sta :='&below5years';
insert into LIBRARY value('sta') âHERE PUBLISHED<5;
sta :='&below10years';
insert into LIBRARY value('sta') âHERE PUBLISHED<10;
sta :='&below19years';
insert into LIBRARY value('sta') âHERE PUBLISHED<=19;
END IF;
END;
/

PROGRM---ü)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
AbdulQader(SQL)>pcreate table book1(book_no number(5),title
varchar2(15),publisher varchar2(15),author varchar2(25),status
varchar2(15),date_of_purchase date);

QUEREIS:-
(i)

(ii)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

PROGRM---üù)

AbdulQader(SQL)>pCREATE TABLE STUDENT(ROLL_NO


NUMBER(15)PRIMARY KEY,S_NAME
VARCHAR2(25),DATE_OF_BIRTH date,COURCE_ID NUMBER(10));
Table created.

AbdulQader(SQL)>pCREATE TABLE COURCE(COURCE_ID


NUMBER(5),NAME VARCHAR2(10),FEE NUMBER(10),DURATION
VARCHAR2(10));
Table created.

ACCEPTING THE DATA FROM A FORM:-


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

QUEREIS:-
(i)
AbdulQader(SQL)>SELECT S_NAME,ROLL_NO,DATE_OF_BIRTH
FROM STUDENT WHERE DATE_OF_BIRTH<='31-DEC-1991';

(ii)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
AbdulQader(SQL)>pselect cource_id,name,fee from cource where
fee>26700;

PROGRM---ü)

AbdulQader(SQL)>create table item(item_code number(5),item_name


varchar2(20),qty_in_stock number(10),reorder_level number(7));
Table created.
AbdulQader(SQL)>create table supplier(supp_code
number(5),supp_name varchar2(25),address varchar2(25));
Table created.
AbdulQader(SQL)>create table can_supply(supp_code
number(5),item_code number(5));
Table created.


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

ACCEPTING THE DATA FROM A FORM:-

QUEREIS:-
(i)
AbdulQader(SQL)>SELECT SUPP_CODE,SUPP_NAME FROM
SUPPLIER WHERE SUPP_CODE IN(SELECT ITEM_CODE FROM ITEM
WHERE ITEM_CODE IN(ITEM_CODE));


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(ii)
AbdulQader(SQL)>select item_code,item_name from item where
item_code not in(select supp_code from supplier where
supp_code>100);

PROGRM---ü)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
AbdulQader(SQL)>create table branch(branch_id
number(6),branch_name varchar2(25),pcust_city varchar2(25),cust_id
number(5));
Table created.

AbdulQader(SQL)>create table customer(cust_id


number(5),cust_name varchar2(25),cust_city varchar2(25),branch_id
number(5));
Table created.

ACCEPTING THE DATA FROM A FORM:-

QUEREIS:-
(i)
AbdulQader(SQL)>SELECT CUST_ID,CUST_CITY,BRANCH_NAME
FROM BRANCH WHERE CUST_CITY=BRANCH_NAME;


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(ii)
AbdulQader(SQL)>select cust_id,cust_name,cust_city from customer
where cust_city not in(select branch_name from branch where
branch_id>100);


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

PROGRM---ü)

AbdulQader(SQL)>create table book(book_no number(5),title


varchar2(15),publisher varchar2(15),status
varchar2(15),date_of_purchase date, year number(5));
Table created.

AbdulQader(SQL)>create table member(member_id number(5),name


varchar2(15),number_of_books_issued number(4),max_limit
number(5));
Table created.

AbdulQader(SQL)>create table book_issue(book_no


number(8),member_id number(6),date_of_issue number(12))
Table created.

ACCEPTING THE DATA FROM FORMS:


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

QUERIES:
(i)
AbdulQader(SQL)>SELECT BOOK_NO,TITLE,DATE_OF_PURCHASE
FROM BOOK WHERE DATE_OF_PURCHASE<'27-SEP-2009';


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(ii)
AbdulQader(SQL)>pselect member_id,name,
number_of_books_issued,max_limit from member where
number_of_books_issued>5;


 PROGRM---ü)




 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
è  All the data are same which we are previously seen(program-ü8).


 

ÿ
declare
cursor prog IS select book_no,member_id,
date_of_issued,due_date from book_issued
where book_no>100;
book number(10);
mem number(10);
dateissued number(15);
duedate number(15);
begin
open prog;
DBMS_OUTPUT.PUT_LINE(' BOOK_NO MEMBER_ID DATE_OF_ISSUED
DUE_DATE ');
DBMS_OUTPUT.PUT_LINE('-------- ------------ --------------- ------------');
LOOP
FETCH PROG INTO book,mem,dateissued,duedate;
exit when(Dateissued<=8);
dbms_output.put_line(book||' '||mem||' '||dateissued||' '||duedate);
end loop;
end;




 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

 

 PROGRM---üÔ)


AbdulQader(SQL)>  
  ÔÔ !

*!
 " ù) " +  +,*" ,  ù),  (! +
 ),  ,  Ôù), ,  Ôù));
Table created.

AbdulQader(SQL)>  
  * ÔÔ !

*!
 " ù)      ÔÔ !

*!)," 
 " ù),   " ù));
Table created.



(A)











 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )





(B)
(i)
AbdulQader(SQL)>SELECT
STUDENT11.S_NAME,STUDENT11.DISTRICT,STUDENT_RANK11.RAN
K FROM STUDENT11,STUDENT_RANK11
WHERE STUDENT11.ROLL_NO=STUDENT_RANK11.ROLL_NO AND
STUDENT_RANK11.RANK=505;


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

 (ii)

   ÔÔ !

*!,   ÔÔ *" ,


  ÔÔ  (! +,  * ÔÔ   !"   ÔÔ,
  * ÔÔ    ÔÔ  (! +-$BC$ 
  * ÔÔ -ùù 
  ÔÔ !

*!-  * ÔÔ !

*!;
/










 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )


 PROGRM---üÔÔ)



AbdulQader(SQL)> create table student17(roll_no number(5),name
varchar2(25),age date,course_id number(5)primary key);
T
   Î

AbdulQader(SQL)>create table course17(course_id
number(5)references student17(course_id),c_name char(6),fee
number(5,2),duration number(4));
T
  

ÿ
âE ARE ALREADY CREATED TABLES and FORM OF BOTH IN THE PROGRAM
OF--üù
Let us create (b),

Bp
ppppp
pipp
AbdulQader(SQL)>SELECT STUDENT17.ROLL_NO,
STUDENT17.NAME,STUDENT17.AGE,COURSE17.COURSE_ID,COURS
E17.C_NAME FROM STUDENT17,COURSE17 WHERE
COURSE17.C_NAME='MCA' AND STUDENT17.AGE BETWEEN '01-
JAN-1991' ANd '31-DEC-1992';


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’ 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p p
p p
p
p
p
p
p
p
p











 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )




PROGRM---üÔ)


ÿâE ARE ALREADY SAâ and CREATED IN THE PROGRAM OF-ü5 5;
Bÿ
declare
C1 NUMBER(10);
COU VARCHAR2(10);
F NUMBER(10);
i varchar2(3);
a varchar2(15);
b varchar2(15);
D number(5);
b e g in
COU :='&COURCE';
select COURCE_ID,name,FEE,DURATION,status into C1,a,F,D,b from
cource where NAME=COU;
IF a='COU'
then
L OOP
A :=A+1;
EXIT WHEN I>10;
IF A<5
THEN
UPDATE COURCE SET STATUS='NOT OFFERED' WHERE NAME='COU';
DBMS_OUTPUT.PUT_LINE('OFFERED NOT ALLOWED WRITTEN TO
STATUS SUCCESSFULLY');
END IF;
END LOOP;
END IF;
END;


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )


 PROGRM---üÔ)

 
)âE ARE ALREADY SAâ IN THE PROGRAM OFü6
6

(B ) BEFORE PL/SQL CODE WRITTEN:-


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )


 

 !  !(!   

 "*! , "*" ,q+**!, !  *
,
 !"  " 
 "*! .Ô;
  " ù);
  " ù);
  " ù);
 ,  Ôù);
 (
!   !(! ;
DBM*OUTPUT PUT*%NE$%TEM*CODE %TEM*NME TY*%N*TOCK
REORDER*EVE$);
DBM*OUTPUT PUT*%NE$---------- --------------- -------------- -------------$);
OOP


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
ETCH PROGOURT %NTO ,,,;
 /-
 
DBM*OUTPUT PUT*%NE 00$ $0000$ $0000$ $00);
 ;
1    !(! 2NOTOUND;

!!;
; '' AFTER PL/SQL CODE WRITTEN:-
/

  


 PROGRM---üÔ)



)3-.6*$ '.c*;,Î


(B)








 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )










 

  " Ô);
 ,  ù);
 ,  ù);
 ,  ù);
 ( 

  *! , * " ,  ,  ! ,,,  !"  

   * !  - Ô ÔÔ;
   . Ô
 


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
  
    -$%MPORT NT$   *!
ÔÔÔ,,,,ùùù,,,, ,ÔÔ);
 ;
;













 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )











 PROGRM---üÔù)







)







 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )







B)



 
$/"$-*
 DECRE
 NUMBERù);
B NUMBERÔ);
C VRCHRù);
BEG%N
EECT RO*NO,UB*OPTED,TTU %NTO ,B,C ROM
TUDENTÔ HERE RO*NO-Ô;
% B/-ù
THEN
UPDTE TUDENTÔ ET TTU-$NOT OERED$ HERE
UB*OPTED/-ù;


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL
) PROGRAMMING
DBM*OUTPUT PUT*%NE$UCCE%VEY UPDTE TO TTU$);
DBM*OUTPUT PUT*%NE$NOT OERED HERE UB*OPTED
TET ù$);
END %;
END;
/








 PROGRM---üÔ)


AbdulQader(SQL)>CRETE TBE UBJECTUB*%D
NUMBERù),UB*NME VRCHRù),CUTY*CODE VRCHR


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD  
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
),PEC%%3T%ON VRCHR),TTU VRCHR));
Table created.

  ).%NERT %NTO UBJECT VUE
4UB*%D,$4UB*NME$,$4CUTY*CODE$,$4PEC%%3T%ON$);

)  
+    ! "  
  !( "  " Ôù
B)

Pl/sql code:-
DECRE
 NUMBERù);
B ,  );
C VRCHRù);
BEG%N
EECT  *,
+*! ,TTU %NTO ,B,C ROM  5 
HERE  *-Ô;
% . --B-$NOT OERED$
THEN
UPDTE  5  ET TTU-$NOT OERED$ HERE

+*! -$NOT OERED$;
END %;
DBM*OUTPUT PUT*%NE$UCCE%VEY UPDTE TO TTU$);


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL
) PROGRAMMING
DBM*OUTPUT PUT*%NE$NOT OERED HERE 
+ " "
  ! ! $);
END;

PROGRM---üÔ)

)p 
+   

B)
)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

p
ii)

PROGRM---üÔ)
)
+   
B)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
(i)

(ii)

PROGRM---üÔ)

)
+   
B)
(i)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD ’
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(ii)

PROGRM---ü)

AbdulQader(SQL)>  
   !  " ù) " +  +,


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )
"   " ù), (! +  ù), ,  ù));
Table created.

AbdulQader(SQL)>  
    !  " ù)   
   !),"   " ù),   " ù));
Table created.

AndulQader(SQL)>select *from student8; select *from studentrank8;

RNO MARKS CATEG STATE RNO MARKS RANK


--------- ---------- ----- ---------------------- ---------- ---------- ----------
1 1000 oc andhra Pradesh 1 159 20
2 980 bc tamilnadu 2 666 500
3 250 bc tamilnadu 3 1000 99
4 1325 oc andhra Pradesh 4 450 450
5 555 oc tamilnadu 5 850 950
6 350 oc tamilnadu 6 750 255
7 654 bc andhra Pradesh 7 774 56
8 587 oc andhra pradesh 8 656 79
9 741 oc tamilnadu 9 850 129
10 959 bc tamilnadu 10 299 255
11 258 bc andhra Pradesh 11 598 366

11 rows selected. 11 rows selected.

(A)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(B)
(i)
AndulQader(SQL)>select studentrank8.rno,studentrank8.rank,
student8.state from studentrank8,student8 where
studentrank8.rno=student8.rno and studentrank8.rank>100 and
student8.state='tamilnadu';

(ii)
AndulQader(SQL)>select studentrank8.rno,studentrank8.rank,
student8.category,student8.state
from studentrank8,student8 where studentrank8.rank>100
and student8.category='bc' and student8.state='andhra pradesh';


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD 
c  ›  
  ROLL NO=’ ’’ 023
Contact me=9700064061

NI
 C S
 NICS)( SQL , PL/SQL PROGRAMMING )

(i) (ii)


 DBMS=LAB-V{NOV/DEC-2009} M.C.A II/I üDBMB)RECORD