view adalah objek di
dalam database yang berisi kumpulan kolom yang dihasilkan dari perintah SELECT.
Dengan kata lain yang lebih sederhana, view adalah objek yang menyimpan hasil
query, baik dari satu tabel atau lebih, didalamdatabase view juga sering
dinamakan sebagai “tabel virtual”, karena view sebenarnya tidak memiliki data.
Data yang ditampilkan oleh oleh sebuah view diambil dari tabel-tabel aktual
yang disertakan dalam SELECT.
View dalam database
memiliki beberapa kegunaan sebagai berikut:
1. Membatasi
akses database
2. Membuat
query kompleks secara penuh
3. Mengijinkan
independensi data
4. Untk
menampilkan view (pandangan) data yang berbeda dari data yang sama
View
memiliki dua tipe, yaitu simple view dan complex view. Perbedaan dari tipe view
tersebut terletak dari fitur query yang digunakan didalam pembuatan view
CONTOH SINTAK
MELALUI SQL 2000:
1. Membuat view table FASILITAS, KAMAR
Masukan query:
create view view_fasilitas AS
select*from FASILITAS
select*from view_fasilitas
create view view_kamar AS
select*from KAMAR
select*from view_kamar
2. Modifikasi view
Masukan query:
create view test AS
select ID_TAMU, NAMA, ID_PESAN, ID_TRANSAKSI from TAMU
where ID_PESAN = 'a1'
select*from test
alter view test AS
select ID_TAMU,NAMA from TAMU
where ID_PESAN = 'a2'
select*from test
MELALUI ORACLE:
1. View table TAMU
create view view_tamu AS
select * from TAMU
select * from view_tamu
2. View table PETUGAS
create view view_petugas AS
select * from PETUGAS
select * from view_petugas
3. View table KAMAR
create view view_kamar AS
select * from KAMAR
select * from view_kamar
4. View table RESTAURAN
create view view_restauran AS
select * from RESTAURAN
select * from view_restauran
5. View table KARTU KREDIT
create view view_kartu_kredit AS
select * from KARTU_KREDIT
select * from view_kartu_kredit
6. View table MAKAN
create view view_makan AS
select * from MAKAN
select * from view_makan
7. View table MEETING ROOM
create view view_meeting_room AS
select * from MEETING_ROOM
select * from view_meeting_room
8. View table TRANSAKSI
create view view_transaksi AS
select * from TRANSAKSI
select * from view_transaksi
9. View table TUNAI
create view view_tunai AS
select * from TUNAI
select * from view_tunai
10. View table MELAYANI
create view view_melayani AS
select * from MELAYANI
select * from view_melayani
11. View table MENYAJIKAN
create view view_menyajikan AS
select * from MENYAJIKAN
select * from view_menyajikan
12. View table MENYEWA
create view view_menyewa AS
select * from MENYEWA
select * from view_menyewa
13. View table MENYIAPKAN
create view view_menyiapkan AS
select * from MENYIAPKAN
select * from view_menyiapkan
14. View table PESAN
create view view_pesan AS
select * from PESAN
select * from view_pesan
# Modifikasi View
create view view_restauran1 AS
select ID_RESTO, JUMLAH_MEJA, WAKTU_PESAN
from RESTAURAN
where JUMLAH_MEJA = '2'
select * from view_restauran1;
create view view_kamar1 AS
select ID_KAMAR, JUMLAH_KAMAR, JENIS_KAMAR, HARGA_KAMAR
from KAMAR
where JENIS_KAMAR = 'vip'
select * from view_kamar1;
create view view_kartu_kredit1 AS
select ID_TRANSAKSI, DOWN_PAYMENT, LAMA_INAP ,TOTAL_PEMBAYARAN, NO_KARTU
from KARTU_KREDIT
where DOWN_PAYMENT = '300000'
select * from view_kartu_kredit1;
create view view_meeting_room1 AS
select ID_METROOM, LARGE_ROOM, SMALL_ROOM
from MEETING_ROOM
where LARGE_ROOM = '1'
select * from view_meeting_room1;
CREATE view view_tamu1 AS
select a.ID_TAMU, a.ID_TRANSAKSI, a.NAMA, a.ALAMAT, a.NO_TELP, b.ID_PETUGAS, b.NAMA_PETUGAS
from TAMU a, PETUGAS b
where a.ID_TAMU= 'it1' AND b.NAMA_PETUGAS like '%krewak%'
select * from view_tamu1;
No comments:
Post a Comment