0% found this document useful (0 votes)
39 views9 pages

Laporan I Praktikum Bahasa Pemrograman SQL: Disusun Oleh

This document contains the report of a SQL programming practice that creates databases, tables, and inserts data. It summarizes the creation of databases named "sl3" and tables such as "mahasiswa", "matakuliah", and "nilai". It also inserts sample data and performs queries. Additional tables like "pelanggan", "akun", and "tabungan" are created to represent customer and account data.

Uploaded by

Wahyu Wulan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views9 pages

Laporan I Praktikum Bahasa Pemrograman SQL: Disusun Oleh

This document contains the report of a SQL programming practice that creates databases, tables, and inserts data. It summarizes the creation of databases named "sl3" and tables such as "mahasiswa", "matakuliah", and "nilai". It also inserts sample data and performs queries. Additional tables like "pelanggan", "akun", and "tabungan" are created to represent customer and account data.

Uploaded by

Wahyu Wulan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

LAPORAN I

PRAKTIKUM BAHASA PEMROGRAMAN SQL

Disusun Oleh
Nama

: Wahyu Wulan M. Jannah

Nim

: 091051090

Kelompok/
No. Komp : SL03/17

JURUSAN TEKNIK INFORMATIKA


FAKULTAS TEKNOLOGI INDUSTRI
INSTITUT SAINS & TEKNOLOGI AKPRIND
YOGYAKARTA
2012

Microsoft Windows XP [Version 5.1.2600]


(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd c:\wamp\bin\mysql\mysql5.0.51b\bin
C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+-------------------------+
| Database

+-------------------------+
| information_schema |
| mysql

+-------------------------+
2 rows in set (0.05 sec)
mysql> CREATE Database sl3;
Query OK, 1 row affected (0.02 sec)

mysql> use sl3;


Database changed

mysql> create table mahasiswa(nim varchar(9), nama varchar(30), alamat varchar(4


0), primary key (nim)) type=innodb;
Query OK, 0 rows affected, 1 warning (0.06 sec)
mysql> create table matakuliah(kode_mk varchar(8), nama_mk varchar(20), sks int(
2), primary key (kode_mk)) type=innodb;
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> create table nilai(nim varchar(9), kode_mk varchar(8), nilai int(2), prim
ary key (nim, kode_mk), foreign key (nim) references mahasiswa (nim) on delete c
ascade on update cascade, foreign key (kode_mk) references matakuliah (kode_mk)
on delete cascade on update cascade) type=innodb;
Query OK, 0 rows affected, 1 warning (0.08 sec)

mysql> insert into mahasiswa value('002','Deni','Yogyakarta');


Query OK, 1 row affected (0.05 sec)

mysql> insert into mahasiswa value('012','Liliek','Yogyakarta');


Query OK, 1 row affected (0.03 sec)

mysql> insert into mahasiswa value('019','Sule','Bandung');


Query OK, 1 row affected (0.01 sec)

mysql> select*from mahasiswa;


+-----+--------+--------------+
| nim | nama | alamat

+-----+--------+--------------+
| 002 | Deni | Yogyakarta |
| 012 | Liliek | Yogyakarta |
| 019 | Sule | Bandung

+-----+--------+---------------+
3 rows in set (0.02 sec)
mysql> desc mahasiswa;
+--------+---------------+------+-----+------------+-------+
| Field | Type

| Null | Key | Default

| Extra |

+--------+---------------+------+-----+------------+-------+
| nim

| varchar(9)

| NO | PRI |

| nama | varchar(30) | YES |

| NULL

| alamat | varchar(40) | YES |

| NULL

+--------+---------------+-------+-----+-----------+-------+
3 rows in set (0.03 sec)
mysql> insert into matakuliah value('0001','Bahasa SQL','1');
Query OK, 1 row affected (0.03 sec)
mysql> insert into matakuliah value('0002','Reka-reka web','2');
Query OK, 1 row affected (0.03 sec)

mysql> select*from matakuliah;


+---------+-------------------+------+
| kode_mk | nama_mk

| sks |

+---------+-------------------+------+
| 0001

| Bahasa SQL

1 |

| 0002

| Reka-reka web |

2 |

+---------+-------------------+------+
2 rows in set (0.00 sec)
mysql> desc nilai;
+------------+-------------+------+-----+----------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+------------+-------------+------+------+---------+-------+
| nim

| varchar(9) | NO | PRI |

| kode_mk | varchar(8) | NO | PRI |

| nilai

| int(2)

| YES |

| NULL

+------------+-------------+------+-----+-----------+-----+
3 rows in set (0.00 sec)
mysql> insert into nilai values('002','0001',86);
Query OK, 1 row affected (0.02 sec)
mysql> insert into nilai values('012','0001',83);

Query OK, 1 row affected (0.02 sec)

mysql> insert into nilai values('019','0001',60);


Query OK, 1 row affected (0.01 sec)

mysql> select*from nilai;


+-----+------------+------+
| nim | kode_mk | nilai |
+-----+------------+------+
| 002 | 0001

86 |

| 012 | 0001

83 |

| 019 | 0001

60 |

+-----+------------+-------+
3 rows in set (0.00 sec)

mysql> create table pelanggan(id_pelanggan varchar(12), nama_pelanggan varchar(3


0), alamat varchar(30), telepon varchar(12), primary key (id_pelanggan)) type=in
nodb;
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> create table akun(id_akun varchar(12), id_cabang varchar(6), simpanan int


, primary key (id_akun)) type=innodb;
Query OK, 0 rows affected, 1 warning (0.06 sec)
mysql> create table tabungan(id_pelanggan varchar(12), id_akun varchar(12), tabu
ng int, primary key (id_pelanggan, id_akun), foreign key (id_pelanggan) referenc
es pelanggan (id_pelanggan) on delete cascade on update cascade, foreign key (id
_akun) references akun (id_akun) on delete cascade on update cascade) type=innod
b;
Query OK, 0 rows affected, 1 warning (0.08 sec)

mysql> insert into pelanggan value('001002003004','Liliek Prasetya','Jl.Bung Kar


no No.12','081393300012');
Query OK, 1 row affected (0.03 sec)

mysql> insert into pelanggan value('002003004005','Bagong Naufal','Jl.Buntu No.9


9','081393123456');
Query OK, 1 row affected (0.01 sec)

mysql> insert into pelanggan value('003004005006','Sasa Sisilia','Jl.Jalan No.65


A','085983123456');
Query OK, 1 row affected (0.03 sec)

mysql> select*from pelanggan;


+------------------+---------------------+---------------------------+-------------------+
| id_pelanggan | nama_pelanggan | alamat

| telepon

+------------------+---------------------+---------------------------+-------------------+
| 001002003004 | Liliek Prasetya | Jl.Bung Karno No.12 | 081393300012 |
| 002003004005 | Bagong Naufal

| Jl.Buntu No.99

| 081393123456 |

| 003004005006 | Sasa Sisilia

| Jl.Jalan No.65A

| 085983123456 |

+-------------------+---------------------+---------------------------+------------------+
3 rows in set (0.00 sec)
mysql> insert into akun value('100200300400','123987',6000000);
Query OK, 1 row affected (0.03 sec)

mysql> insert into akun value('123456789876','123456',80000000);


Query OK, 1 row affected (0.03 sec)

mysql> insert into akun value('987654321234','123987',60000000);

Query OK, 1 row affected (0.03 sec)

mysql> select*from akun;


+------------------+-------------+------------+
| id_akun

| id_cabang | simpanan |

+------------------+-------------+------------+
| 100200300400 | 123987

| 6000000 |

| 123456789876 | 123456

| 80000000 |

| 987654321234 | 123987

| 60000000 |

+------------------+-------------+------------+
3 rows in set (0.00 sec)

mysql> insert into tabungan value('001002003004','100200300400',160000);


Query OK, 1 row affected (0.01 sec)

mysql> insert into tabungan value('002003004005','123456789876',1200000);


Query OK, 1 row affected (0.03 sec)

mysql> insert into tabungan value('003004005006','987654321234',1000000);


Query OK, 1 row affected (0.01 sec)
mysql> select*from tabungan;

+-------------------+------------------+-----------+
| id_pelanggan

| id_akun

| tabung

+-------------------+------------------+-----------+
| 001002003004 | 100200300400 | 160000 |

| 002003004005 | 123456789876 | 1200000 |


| 003004005006 | 987654321234 | 1000000 |
+-------------------+------------------+-----------+
3 rows in set (0.00 sec)
mysql> create table cabang(id_cabang varchar(6) primary key, nama_cabang varchar
(25), alamat varchar(30), aset int);
Query OK, 0 rows affected (0.06 sec)
mysql> desc cabang;
+-----------------+--------------+-------+-----+-----------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+-----------------+--------------+-------+-----+-----------+-------+
| id_cabang

| varchar(6) | NO | PRI | NULL |

| nama_cabang | varchar(25) | YES |

| NULL |

| alamat

| varchar(30) | YES |

| NULL

| aset

| int(11)

| NULL |

| YES |

+----------------+----------------+-------+-----+-----------+------+
4 rows in set (0.02 sec)

mysql> insert into cabang value('123456','IST Akprind Yogyakarta','Komplek Balap


an',130000000);
Query OK, 1 row affected (0.38 sec)

mysql> insert into cabang value('123987','Babarsari','Jl. Dirgantara III',170000


000);
Query OK, 1 row affected (0.39 sec)

mysql> insert into cabang value('987654','Jakal','Jl. Kaliurang',200000000);


Query OK, 1 row affected (0.08 sec)

mysql> alter table cabang add alamat varchar(30);


Query OK, 0 rows affected (0.03 sec)

mysql> select*from cabang;


+-----------+-------------------------------+-------------------------+--------------+
| id_cabang | nama_cabang

| alamat

| aset

+-----------+-------------------------------+-------------------------+--------------+
| 123456

| IST Akprind Yogyakarta | Komplek Balapan

| 130000000 |

| 123987

| Babarsari

| Jl. Dirgantara III

| 170000000 |

| 987654

| Jakal

| Jl. Kaliurang

| 200000000 |

+-----------+-------------------------------+-------------------------+--------------+
3 rows in set (0.00 sec)

You might also like