Professional Documents
Culture Documents
0]
Student Information :
roll name course book_id title doi dor
11
101 ram
oracle
12
13
------------------------------------------------------------16
102 hari
oracle
18
21
-------------------------------------------------------------T1
T2
----------roll (pk)
book_id
name
title
course
doi
dor
roll (fk)
Collections (8.0)
--------------------A group of similar rows stored at one location.
2 Types:
1. Nested Tables
Table with in a table
A column holds a table of contents in it.
2. Varrying Arrays ( Varrays )
It is an array of elements stored in a column.
Nested Table Example:
i). create type book_type as object
( book_id number(4), title varchar2(20),
doi date, dor date );
/
* Object representing Table of books
ii). create type books is table of book_type;
iii). create table stu_lib (roll number(3),
name varchar2(20), course varchar2(20),
binfo books) Nested table binfo store as
book_table;
Ex:
* Adding a Book ( Only 1 book allowed )
insert into
THE(select binfo from stu_lib where roll = 101)
values(book_type(15,'DBA',sysdate,sysdate + 10));
* Changing a Book details
Update
THE(select binfo from stu_lib where roll = 101)
set dor = dor + 3 where book_id = 12;
Update
THE(select binfo from stu_lib where roll = 101)
set title = 'Tuning' where book_id = 15;
* Removing a book info
delete from
THE(select binfo from stu_lib where roll = 101)
where book_id = 12;
--------------------------------------------------------------Varrying Array Example:
i) create type book_type as object
(book_id number(4), title varchar2(20), doi date,
dor date);
/
* Object representing Array of books
ii) create type barray is varray(3) of book_type;
iii) create table library (roll number(3),name
varchar2(20), binfo barray);
varchar2(20), course
collections.
Tools) .
--------------------------------------------------------------Ex 2: Varray
create type blist is varray(5) of varchar2(25);
create table items(itno number(3),
name varchar2(20), brands blist);
insert into items values(101,'Television',
blist('SONY','LG','ONIDA','SAMSUNG','TCL'));
insert into items values
FB'));
(102,'Micro-oven',blist('LG','ONIDA','I
blist('LG','ONIDA','IFB','KENSTAR','SA
desc blist
desc items
select * from items;
select name,brands from items;
--------------------------------------------------------------Data Partitioning with Partition Tables:
Used to manage huge loads of data in table by
ns.
Improves the performance of Oracle while
ng data from Huge Tables.
Ex:
create table emp_part (ecode number(2) primary
number(10,2))
partition by range (ecode)
( partition p1 values less than (11),
partition p2 values less than (21),
partition p3 values less than (31),
partition p4 values less than (41),
partition p5 values less than (maxvalue));
Partition Limits :
p1 -- 1 - 10
p2 -- 11 - 20
p3 -- 21 - 30
p4 -- 31 - 40
p5 -- 41 - N
insert into emp_part values (1,'RAM',12000);
insert into emp_part values (3,'RAM',13000);
insert into emp_part values (7,'RAM',17000);
insert into emp_part values (11,'RAM',2000);
insert into emp_part values (13,'RAM',3000);
insert into emp_part values (17,'RAM',7000);
insert into emp_part values (21,'RAM',22000);
insert into emp_part values (23,'RAM',23000);
insert into emp_part values (27,'RAM',27000);
insert into emp_part values (31,'RAM',10000);
insert into emp_part values (33,'RAM',14000);
insert into emp_part values (37,'RAM',15000);
insert
insert
insert
insert
into
into
into
into
emp_part
emp_part
emp_part
emp_part
values
values
values
values
(41,'RAM',31000);
(43,'RAM',33000);
(47,'RAM',37000);
(67,'RAM',57000);
statement.
cursor.
programs.
programs.
parameter :
||' '||vjob);
end loop;
close pcur;
end;
Re-using Ref cursor:
declare
scur pack1.rcur;
vroll number(3); vname varchar2(20);
vfee number(5);
begin
open scur for select roll,sname,fee_paid from
stu_info where course =
'&course';
loop
fetch scur into vroll,vname,vfee;
exit when scur%notfound;
dopl(vroll||' '||vname||' '||vfee);
end loop;
close scur;
end;
--------------------------------------------------------------Important Topics:
Joins, 9i Joins, Constraints, Sub queries, Views, Index, clusters, Pseudo colu
mns, All 8.0 features, Date Manipulations, Procedures, Functions, Triggers, P
ackages, Utilities, Pragma, Autonomous Transactions, Exception_init, Ref curs
ors, Temporary tables, Normalization, Architecture,
Partition Tables, File I
/O.
--------------------------------------------------------------Roles of an Programmer in Oracle : ( Resume )
* Designing the database objects using
Normalization .
* Applying Constraints, Indexes to maintain Data
Integrity while definin
g objects.
* Defining code components like Triggers to apply
User defined restriction
s in database as per client
requirement .
* Defining Procedures , Functions & Packages as
per client requirement
.
* Generating different types of Queries for
reporting purpose.
--------------------------------------------------------------Versions Features:
Oracle 6.0 - It is an DBMS Tool
Oracle 7.x - It is an RDBMS Tool (7.0 / 7.1 / 7.2 /
7.3)
Oracle 8.0 - It supports OOPS Features.(ORDBMS)
New Features: Objects , Object with Methods, Nested Tables, Varrying Arrays,
Rename, Sharing Columns, Partition Tables, Key Preserved Table, Inline Views,
Scalar Query, File I/O ,Autonoumus Transactions , Trim, Reverse, stddev, vari
ance , ceil, floor ,LOBS, Returning into, Bulk Collect,
bulk bind, Rollup, Cube.
Oracle 8i : It is in_built with JAVA
New Features: SQLJ, Iterators, Temporary Tables,
ggers, case,
Materialized views.
Database .
Using Aggregates in Returning into clause, spool Append, Using Regular Exp
ressions while searching character data . Provides High performance .
Supported with More Advanced Features for DBA.
--------------------------------------------------------------Oracle 8i:
Java is a Built_in software
Supports to execute Java programs with in oracle
server or client System.
SQLJ : It is an Transalator.
It will check for SQL stmt syntax errors and
translate the Sql comman
ds into Java equivalent
code. After Translation it returns .Java file .
Sql stmts are provided in below format in Sqlj
)
#sql { DDL, DML , TCL , DCL };
Steps:
Provide Path settings and User details in
em file.
1. Open Notepad and add the Code
2. save file as "filename.sqlj"
3. C:\>sqlj filename.sqlj -- check for sql syntax
and translate into .java file
4. C:\>javac filename.java -- compiles java
.class file
5. C:\>java filename -- Execute .class file and
.
script. ( filename.sqlj
"connect.properties" syst
Iterators:
Used to retrieve data from Oracle table to Java
program. similar to cur
sors in PL/SQL.
2 Types
1. Named Iterator - Similar to cursor with For loop
2. Positional Iterator - Similar to cursor with
Operations
---------------------------------------------------------------