Ko‘rinish (View) yaratish sintaksisi:
CREATE VIEW view_name AS SELECT column1, column2, ...
FROM table_name
WHERE condition;
Misol: “Faqat o‘qish uchun” ko‘rinishini yaratish
CREATE OR REPLACE FORCE VIEW "V_STUD" ("ID", "NAME", "SNAME", "CITY", "BIRTHDAY", "ID_GR") AS SELECT
"ID","NAME","SNAME","CITY","BIRTHDAY","ID_GR" FROM STUDENT WHERE ID_GR=2 WITH READ ONLY
Faqat o‘qish uchun ko‘rinishida WITH READ ONLI xossasi qo‘shiladi.
Ko‘rinishni yaratish uchun RUN tugmasini bosing.
Yuqorida yaratilgan ko‘rinishdan foydalanish uchun
SELECT * FROM V_STUD;
Yangilanuvchi ko‘rinishlarni yaratish
Yuqorida ta’kidlanganidek, yangilanuvchi ko‘rinishlar yordamida bazaviy jadvallarga o‘zgartirishlar kiritish mumkin. Yuqorida yaratilgan v_stud “faqat o‘qish uchun” ko‘rinishini quyidagi amallar yordamida yangilanuvchi ko‘rinishga keltiramiz:
“Oracle Express” ning bosh sahifasidan “Object Brouzer” ni tanlang;
Obyektlar panelining Views bo‘limidan v_stud ko‘rinishini tanlang;
Code tugmasini bosing;
Edit tugmasini bosing;
WITH READ ONLY yozuvini WITH CHECK OPTION yozuviga almashtiring;
Compile tugmasini bosing;
PL/SQL code successfully compiled kompilyatiya muvafaqqiyatli o‘tganligidan darak beradi.
Yaratilgan ko‘rinishga INSERT, UPDATE, DELETE operatorlarini qo‘llash mumkin.
Quyidagi kodni tekshirib ko‘ring:
INSERT INTO v_stud (id, name, sname, id_gr) VALUES (null, 'Olimjon', 'Azimov', 3);
Jadvallarni bog‘lash asosida yangilanuvchi ko‘rinishlar yaratish
Talaba hamda guruh jadvallarini o‘zaro bog‘lab (INNER JOIN), yangilanuvchi ko‘rinish yaratish uchun quyidagi amallarni bajaring:
Create | View buyrug‘ini bajaring;
Do'stlaringiz bilan baham: |