Saturday, May 8, 2010

Oracle : varray nasted table

create type tool_ty as object
(toolname varchar(25))

Type created.


create or replace type tools_va as varray(5) of varchar(25)

Type created.


create table borrower
(name varchar(25),
tools tools_va,
constraint borrower_pk primary key(name));

Table created.


SQL> desc borrower
Name Null? Type
------------------------------- -------- ----
NAME NOT NULL VARCHAR2(25)
TOOLS TOOLS_VA


insert into borrower values('abc',tools_va('hammer','sledge','ax'))




select * from borrower


NAME
-------------------------
TOOLS
----------------------------------------------------------------------------------------------------
abc
TOOLS_VA('hammer', 'sledge', 'ax')


*********************************************************
nasted table

create or replace type lib_ty as object
(bk_name varchar(25),
bk_issue_date date)
create type lib_ty as table of lib;

create type lib_nt as table of lib_ty;

create table student
(no number(3),
name varchar(30),
lib lib_nt)
nested table lib store as lib_nt_tab

insert into student values
(1,'abc',
lib_nt(lib_ty('c++','31-mar-10'),
lib_ty('java','12-feb-2010')))

No comments:

Post a Comment