Oracle - OODB
Useful commands / užitečné příkazy
- SELECT * FROM user_types
- zobrazení všech dostupných uživatelských typů
- DROP TYPE person_t force
- smazání typu person_t (force značí, že se nebere ohled na nějakou závislost)
- SELECT * FROM user_types_attrs WHERE type_name="...."
- zjištění jaké atributy má registrovaný objekt
- SELECT table_name FROM all_all_tables
- vypis vsech dostupnych tabulek v databazi
- SELECT * FROM user_tables
- vypis vsech uzivatelskych tabulek
Inheritance
Vytvoreni dvou datovych typu client_t a salesperson_t, jez existuji under datovym type person_t.
Nad datovym typem person_t je vytvorena tabulka jez je schopna pojmout oba datove typy.
drop table person;
drop type salesperson_t force;
drop type client_t force;
drop type person_t force;
drop type phone_t force;
drop type address_t force;
create type address_t as object (
addressLine1 VARCHAR2(50),
addressLine2 VARCHAR2(50),
town VARCHAR2(50)
);
/
create type phone_t as object (
contactTel1 varchar2(50),
contactTel2 varchar2(50)
);
/
create type person_t as object (
surename varchar2(50),
forename varchar2(50)
) not final;
/
CREATE OR REPLACE TYPE client_t UNDER person_t (
client# number,
address address_t,
phone phone_t
);
/
CREATE OR REPLACE TYPE salesperson_t under person_t (
salesperson# number(6),
dateOfBirth DATE
);
/
CREATE TABLE person of person_t;
INSERT INTO person VALUES ( salesperson_t('Martin','Milicka',12,TO_DATE('01-jan-67','DD-MON-RR') ) );
INSERT INTO person
VALUES (
client_t(
'Martin',
'Milicka',
12,
address_t('Zahorovice asd','druhe pl','Zahorovice'),
phone_t('46041818','46197791')
)
);
INSERT INTO person
VALUES (
client_t(
'Pavel',
'Milicka',
13,
address_t('Prvni pole','druhe pole','Zahorovice'),
phone_t('00000000','878978978')
)
);
Pro vypis pouze urciteho datove typu slouzi klicove slova IS OF.
SELECT * FROM person s
WHERE VALUE(s) IS OF (client_t);
useful links
select from inherited object columns
Basic components of oracle model
Object oriendet features of Oracle
© 2010 Marmil (Martin Milička)