Welcome to Abdul Malik Ikhsan's Blog

View pada Mysql 5.0.41

Posted in mysql docs by samsonasik on July 20, 2007

View bisa dikatakan summary dari tabel atau beberapa tabel, dengan view, kita bisa gabungkan beberapa tabel sekaligus dan view ini tersimpan di sisi server, sehingga nanti penggunaannya tinggal panggil saja, berikut contohnya, :D:\its me\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database forum;
Query OK, 1 row affected (0.00 sec)

mysql> use forum;
Database changed
mysql> create table barang(kode_barang char(3) not null primary key default’0′,n
ama_barang char(30),harga_barang int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into barang values(‘001′,’mobil’,50000000);
Query OK, 1 row affected (0.05 sec)

mysql> create table jual(tgl date,kode char(3),jml_jual int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into jual values(‘2007-01-01′,’001’,3);
Query OK, 1 row affected (0.00 sec)

mysql> create view jualan_view as select DATE_FORMAT(b.tgl,’%d %M %Y’) as tgl,b.kode,a.nama_barang, a.harga_barang,b.jml_jual,(a.harga_barang*b.jml_jual) as total from jual b, barang a where
b.kode=a.kode_barang;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from jualan_view;
==========================================
| tgl  | kode | nama_barang | harga_barang | jml_jual | total  |
===========================================
| 01 January 2007 | 001 | mobil |  50000000  | 3 | 150000000     |
+———————–+——+————-+————–+———-+
1 row in set (0.00 sec)

12 Responses

Subscribe to comments with RSS.

  1. LeiGen said, on August 21, 2007 at 9:59 am

    tolong beritahu saya di mana saya bisa mendapat tutorial mysql database dari awal.
    karna saya belumpernah pake mysql. terimakasih

  2. samsonasik said, on August 21, 2007 at 12:35 pm

    baca aja manualnya di http://dev.mysql.com/doc/

  3. andi said, on June 24, 2008 at 8:58 am

    salam coding… saya mencoba membuat view di mysql kok gak bisa ya… di mysql yog versi mysql saya bawaan dari xammp versi 1.55 kira2 versi minimal nya berapa ya supaya saya bisa buat view dan di save jadi gak perlu nulis query lagi capek dech… tks…

  4. samsonasik said, on June 24, 2008 at 10:45 am

    coba lihat di http://localhost/phpmyadmin/ , di sebelah kanan halaman phpmyadmin, biasanya ditampilkan versi mysql yang kita pakai, setahu saya, baru di Mysql 5 ke atas yang bisa menggunakan view.

  5. epol said, on January 15, 2009 at 3:13 am

    Bos lam knl,
    mo tanya, kalo setting java di vista gmn?
    biar bisa liat hasil scriptnya jalan pa ngak
    gw pke Java Sun 6
    thank’s

  6. samsonasik said, on January 15, 2009 at 9:07 am

    belum pernah setting di vista sih, tp seharusnya mah sama aja :d, coba deh tanya google dulu

  7. herru said, on February 13, 2009 at 12:44 pm

    thanks atas info view nya…!!! mysql 4 blum bisa pake view?

  8. samsonasik said, on February 14, 2009 at 4:30 pm

    belum

  9. wiwit said, on June 14, 2011 at 3:52 pm

    mau tanya doong …
    saya dapet tugas untuk membuat contoh view dengan perintah DDL:
    CREATE
    ALTER
    DROP
    nah saya baru bisa menemukan create view dan drop view saja…
    kalo yang alter view itu gimana yaaa???
    mohon bantuannya
    terima kasih sebelumnya 🙂

  10. samsonasik said, on June 14, 2011 at 4:12 pm

    bisa dibaca di sini :
    http://dev.mysql.com/doc/refman/5.0/en/alter-view.html

  11. mamasheru said, on April 22, 2012 at 12:46 pm

    mas, klo satu DB bisa gx banyak view?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: