Vous êtes sur la page 1sur 6

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 iv) desc book_type desc books desc stu_lib v) insert into stu_lib values(101,'RAM','Oracle9i', books(book_type(11, 'sql' , sysdate, sysdate + 10), book_type(12, 'pl/sql' , sysdate, sysdate + 15), book_type(13, 'DBA' , sysdate, sysdate + 20))); vi) select * from stu_lib; select name,binfo from stu_lib; --------------------------------------------------------------DML on Nested Table: THE - operator is used to perform DML on Nested table. It holds the nested table content in buffer memory for manipulation purpose. 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,

book_table;

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 r2(20), binfo barray); iv) desc book_type desc barray desc library v) insert into library values(101,'RAM','Oracle9i', barray(book_type(11, 'sql' , sysdate,sysdate + 10), book_type(12, 'pl/sql' , sysdate, sysdate + 15), book_type(13, 'DBA' , sysdate, sysdate + 20))); vi) select * from library; select name,binfo from library; Varray Structure: Library roll name course book_id title doi dor 11 101 ram oracle 12 13 --------------------------------------------------------------Nested Table Vs Varray Stored outside the table Stored with in the table DML is allowed DML Not Allowed Stores unlimited data Stores limited data Note: Collections will not support constraints. Long, RAW, LOB data types are not valid in collections. Collections will not support Developer 6i,VB (GUI Tools) . JAVA supports collections. --------------------------------------------------------------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 update items set brands = where itno = 102; (102,'Micro-oven',blist('LG','ONIDA','IFB')); blist('LG','ONIDA','IFB','KENSTAR','SAMSUNG') varchar2(20), course varcha

desc blist desc items select * from items; select name,brands from items; --------------------------------------------------------------- Temporary Table s (8i) --------------------------Used to hold the information in logical memory but not in physical memory.

They hold the data for a particular period of time Ex: 1 Holds the Data until Transaction is Closed create global temporary table temp(c1 date) on commit delete rows; insert into temp values(sysdate); select * from temp; --- 24-may-10 commit; select * from temp; --- no rows Ex: 2 Holds the Data until Session is closed create global temporary table temp(c1 date) on commit preserve rows;

but not permenantly.

insert into temp values(sysdate); select * from temp; --- 24-may-10 commit; select * from temp; --- 24-may-10 exit --- rows are removed ( Temp will be empty ) --------------------------------------------------------------Data Partitioning with Partition Tables: Used to manage huge loads of data in table by creating Logical Partition s. Improves the performance of Oracle while retrieving or manipulating data from Huge Tables. Ex: create table emp_part (ecode number(2) primary key, ename varchar2(20), sal 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);

select * from emp_part; select * from emp_part partition (p2); select * from emp_part partition (p3) where sal > 20000; update emp_part partition (p2) set sal = sal + 3000 ; alter table emp_part drop partition p5; alter table emp_part add partition p5 values less than (51); alter table emp_part add partition p6 values less than (maxvalue); --------------------------------------------------------------Ref Cursors: Dynamic cursors supports to define the cursor without select select statement will be provided while "opening" used to send cursor as an parameter in sub made easy to transfer huge data thru sub Syntax: Type <Ref cursor name> is Ref cursor; create package pack1 as type rcur is ref cursor; end pack1; ** Procedure returning multiple rows thru OUT create or replace procedure get_rows(vdept in cur) is begin open vcur for select empno,ename,sal,job from end; Using Procedure: declare pcur pack1.rcur; veno number(4); vname varchar2(20); vsal number(12,2); vjob varchar2(20); begin -- calling procedure get_rows(30,pcur); -- printing cursor contents dbms_output.put_line(' Employee Details are '); loop fetch pcur into veno,vname,vsal,vjob; exit when pcur%notfound; dbms_output.put_line(veno||' '||vname||' '||vsal ||' '||vjob); end loop; close pcur; end; Re-using Ref cursor: declare scur pack1.rcur; vroll number(3); vname varchar2(20); parameter : number, vcur out pack1.r emp where deptno = vdept; statement. cursor. programs. programs.

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 col umns, All 8.0 features, Date Manipulations, Procedures, Functions, Triggers, Packages, Utilities, Pragma, Autonomous Transactions, Exception_init, Ref cur sors, Temporary tables, Normalization, Architecture, Partition Tables, File I/O. --------------------------------------------------------------Roles of an Developer 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. Drop Column, Instead of Tri

Oracle 9i : Supports Advanced Features of JAVA. New Features : Supports XML . New Date Functions, New General Functions , Multiple Inserts, Merge, Rena me columns & Rename Constraints , 9i Joins,Analytical Functions Oracle 10g : Supports Grid Technology - used to store EJB components directly into Da tabase . Using Aggregates in Returning into clause, spool Append, Using Regular Exp ressions while searching character data . Provides High performance . ---------------------------------------------------------------

Vous aimerez peut-être aussi