Thursday, March 27, 2008

Oracle for Beginner: ORDB with Oracle (I)

If you want to learn about object relational database in Oracle, the first thing that you have to understand is object oriented concept itself. By the way, in what level of your understanding, let we learn about how to implement a simple Oracle's ORBMS.
In Oracle, there are object schema, .i.e., User Define Type (UDT). With this object, we can create any customize type, specially object type. Here is a example:

create or replace type pengajar_t as object (
pengajar_id char(5),
nama varchar(30)
)
/

With customize object type, we can use that as a attribute type for a table.

create table kursus (
kursus_id char(5) primary key,
nama_kursus varchar(50),
pengajar pengajar_t
);

If you want to insert or update for that table, here are an example for how to do that:

insert into kursus values ('K01', 'Air Blender', pengajar_t('X-01','Avatar'));
insert into kursus values ('K02', 'Kamehameha', pengajar_t('X-02','Goku'));
update kursus k set k.pengajar.nama = 'Gohan' where k.pengajar.pengajar_id ='X-02';

1 comment:

Anonymous said...

change your mood,refresh your mind

Visit the Healing the power of music