Dalam Praktek ini memerlukan software XAMPP untuk membuatnya
CMD
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd\
C:\>cd xampp\
C:\xampp>cd mysql\
C:\xampp\mysql>cd bin\
C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database db_toko;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_toko |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.05 sec)
mysql> use db_toko;
Database changed
mysql> create table tb_stok (kode_barang varchar (20) not null primary key,
-> nama_barang varchar (20),
-> jumlah integer,
-> harga integer;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 4
mysql> create table tb_stok (kode_barang varchar (20) not null primary key,
-> nama_barang varchar (20),
-> jumlah integer,
-> harga integer);
Query OK, 0 rows affected (0.09 sec)
mysql> insert into tb_stok value ('B01', 'Buku', '20', '1500'),
-> ('B02', 'Pulpen', '12', '1000');
Query OK, 2 rows affected (0.06 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select*from tb_stok;
+-------------+-------------+--------+-------+
| kode_barang | nama_barang | jumlah | harga |
+-------------+-------------+--------+-------+
| B01 | Buku | 20 | 1500 |
| B02 | Pulpen | 12 | 1000 |
+-------------+-------------+--------+-------+
2 rows in set (0.00 sec)
mysql> select min(jumlah) from tb_stok;
+-------------+
| min(jumlah) |
+-------------+
| 12 |
+-------------+
1 row in set (0.03 sec)
mysql> select*from tb_stok where nama_barang='Buku';
+-------------+-------------+--------+-------+
| kode_barang | nama_barang | jumlah | harga |
+-------------+-------------+--------+-------+
| B01 | Buku | 20 | 1500 |
+-------------+-------------+--------+-------+
1 row in set (0.00 sec)
mysql> select nama_barang from tb_stok;
+-------------+
| nama_barang |
+-------------+
| Buku |
| Pulpen |
+-------------+
2 rows in set (0.00 sec)
mysql>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd\
C:\>cd xampp\
C:\xampp>cd mysql\
C:\xampp\mysql>cd bin\
C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database db_perpustakaan;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_perpustakaan |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.03 sec)
mysql> use db_perpustakaan;
Database changed
mysql> create table tb_petugas (NIP varchar (10) not full primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'full
primary key' at line 1
mysql> create table tb_petugas (NIP varchar (10) not null primary key,
-> nama_petugas varchar (25),
-> jenis_kelamin varchar (10),
-> alamat varchar (30),
-> agama varchar (10));
Query OK, 0 rows affected (0.08 sec)
mysql> create table tb_anggota (NIM varchar (10) not null primary key,
-> nama_anggota varchar (25),
-> jenis_kelamin varchar (10),
-> alamat varchar (30),
-> agama varchar (10));
Query OK, 0 rows affected (0.05 sec)
mysql> create table tb_buku (kode_buku varchar (10) not null primary key,
-> nama_buku varchar (25),
-> penerbit varchar (20),
-> pengarang varchar (25),
-> kota varchar (25));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into tb_petugas value ('00001', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00002', "Surya', 'Laki-Laku', 'Godean', 'Katholik'),
"> ;
"> ";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 2
mysql> insert into tb_petugas value ('00001', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00002', 'Surya', 'Laki-Laku', 'Godean', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ')' at
line 5
mysql> insert into tb_petugas value ('00001', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00002', 'Surya', 'Laki-Laku', 'Godean', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik');
ERROR 1062 (23000): Duplicate entry '00003' for key 'PRIMARY'
mysql> insert into tb_petugas value ('00001', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00002', 'Surya', 'Laki-Laku', 'Godean', 'Katholik'),
-> ('00003', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'),
-> ('00004', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik');
Query OK, 4 rows affected (0.02 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> insert into tb_petugas value ('00005', 'Tini', 'Perempuan', 'Glagahsari',
'Islam');
Query OK, 1 row affected (0.02 sec)
mysql> insert into tb_anggota value ('00001', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00002', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik');
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into tb_anggota value ('00003', 'Tini', 'Perempuan', 'Glagahsari',
'Islam'),
-> ('00004', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik'),
-> ('00005', 'Toko', 'Laki-Laki', 'Kulon Progo', 'Katholik');
Query OK, 3 rows affected (0.03 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> insert into tb_anggota value ('00001', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'm
mmmmm'),
-> ('00002', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('00003', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('00004', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('00005', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm');
ERROR 1062 (23000): Duplicate entry '00001' for key 'PRIMARY'
mysql> insert into tb_anggota value ('000011', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', '
mmmmmm'),
-> ('000012', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000013', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000014', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000015', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm');
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select*from tb_petugas;
+-------+--------------+---------------+-------------+----------+
| NIP | nama_petugas | jenis_kelamin | alamat | agama |
+-------+--------------+---------------+-------------+----------+
| 00001 | Tini | Perempuan | Glagahsari | Islam |
| 00002 | Surya | Laki-Laku | Godean | Katholik |
| 00003 | Toko | Laki-Laki | Kulon Progo | Katholik |
| 00004 | Toko | Laki-Laki | Kulon Progo | Katholik |
| 00005 | Tini | Perempuan | Glagahsari | Islam |
+-------+--------------+---------------+-------------+----------+
5 rows in set (0.00 sec)
mysql> select*from tb_anggota;
+--------+--------------+---------------+-------------+----------+
| NIM | nama_anggota | jenis_kelamin | alamat | agama |
+--------+--------------+---------------+-------------+----------+
| 00001 | Tini | Perempuan | Glagahsari | Islam |
| 000011 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000012 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000013 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000014 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000015 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 00002 | Toko | Laki-Laki | Kulon Progo | Katholik |
| 00003 | Tini | Perempuan | Glagahsari | Islam |
| 00004 | Toko | Laki-Laki | Kulon Progo | Katholik |
| 00005 | Toko | Laki-Laki | Kulon Progo | Katholik |
+--------+--------------+---------------+-------------+----------+
10 rows in set (0.00 sec)
mysql> insert into tb_buku value ('000011', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmm
mmm'),
-> ('000012', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000013', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000014', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm'),
-> ('000015', 'uuuuuuu', 'xxxxxxx', 'nnnnnn', 'mmmmmm');
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select*from tb_buku;
+-----------+-----------+----------+-----------+--------+
| kode_buku | nama_buku | penerbit | pengarang | kota |
+-----------+-----------+----------+-----------+--------+
| 000011 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000012 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000013 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000014 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
| 000015 | uuuuuuu | xxxxxxx | nnnnnn | mmmmmm |
+-----------+-----------+----------+-----------+--------+
5 rows in set (0.00 sec)
mysql>
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database db_penjualan;
Query OK, 1 row affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_penjualan |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.06 sec)
mysql> create database db_ari;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_ari |
| db_penjualan |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
9 rows in set (0.00 sec)
mysql> drop database db_ari;
Query OK, 0 rows affected (0.06 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_penjualan |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.00 sec)
mysql> use db_penjualan;
Database changed
mysql> create table tb_stok
-> (kd_barang varchar (20) not null primary key,
-> nama_barang varchar (20),
-> jumlah integer,
-> harga integer;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 5
mysql> (kd_barang varchar (20) not null primary key,
-> nama_barang varchar (20),
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'kd_ba
rang varchar (20) not null primary key,
nama_barang varchar (20),' at line 1
mysql> create table tb_stok
-> (kd_barang varchar (20) not null primary key,
-> nama_barang varchar (20),
-> jumlah integer,
-> harga integer);
Query OK, 0 rows affected (0.11 sec)
mysql> insert into tb_stok value
-> ('001', 'Buku Tulis', '20', '1500'),
-> ('002', 'Pensil', '20', '2500'),
-> ('003', 'Pulpen', '20', '1000'),
-> ('004', 'Penghapus', '20', '1000'),
-> ('005', 'Penggaris', '20', '1000');
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select*from tb_stok;
+-----------+-------------+--------+-------+
| kd_barang | nama_barang | jumlah | harga |
+-----------+-------------+--------+-------+
| 001 | Buku Tulis | 20 | 1500 |
| 002 | Pensil | 20 | 2500 |
| 003 | Pulpen | 20 | 1000 |
| 004 | Penghapus | 20 | 1000 |
| 005 | Penggaris | 20 | 1000 |
+-----------+-------------+--------+-------+
5 rows in set (0.00 sec)
mysql> create table tb_transaksi;
ERROR 1113 (42000): A table must have at least 1 column
mysql> create table tb_transaksi
-> (kd_transaksi varchar (20) not null primary key,
-> tgl_transaksi date,
-> (kd_barang varchar (20),
-> qty integer,
-> harga_satuan integer,
-> sub_total integer;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '(kd_b
arang varchar (20),
qty integer,
harga_satuan integer,
sub_total integer' at line 4
mysql> (kd_transaksi varchar (20) not null primary key,
-> tgl_transaksi date,
-> kd_barang varchar (20),
-> qty integer,
-> harga_satuan integer,
-> sub_total integer;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'kd_tr
ansaksi varchar (20) not null primary key,
tgl_transaksi date,
kd_barang va' at line 1
mysql> create table tb_transaksi
-> (kd_transaksi varchar (20) not null primary key,
-> tgl_transaksi date,
-> kd_barang varchar (20),
-> qty integer,
-> harga_satuan integer,
-> sub_total integer);
Query OK, 0 rows affected (0.05 sec)
mysql> insert into tb_transaksi value
-> ('001', '2012-11-26', '003', 'Pulpen', '2', '1000', '2000'),
-> ('002', '2012-11-25', '002', 'Pensil', '2', '2500', '5000'),
-> ('003', '2012-11-25', '001', 'Buku Tulis', '2', '1500', '3000');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into tb_transaksi value
-> ('001', '2012-11-26', 'B03', 'Pulpen', '2', '1000', '2000'),
-> ('002', '2012-11-25', 'B02', 'Pensil', '2', '2500', '5000'),
-> ('003', '2012-11-25', 'B01', 'Buku Tulis', '2', '1500', '3000');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> ('001', '2012-11-25', 'B03', 'Pulpen', '2', '1000', '2000'),
-> ('001', '2012-11-25', 'B03', 'Pulpen', '2', '1000', '2000');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ''001'
, '2012-11-25', 'B03', 'Pulpen', '2', '1000', '2000'),
('001', '2012-11-25'' at line 1
mysql> insert into tb_transaksi value
-> ('001', '2012-11-25', 'B03', 'Pulpen', '2', '1000', '2000'),
-> ('002', '2012-11-25', 'B02', 'Pensil', '2', '2500', '5000'),
-> ('003', '2012-11-25', 'B01', 'Buku Tulis', '2', '1500', '3000');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into tb_transaksi value
-> ('B01', '2012-11-26', '003', 'Pulpen', '2', '1000', '2000'),
-> ('B02', '2012-11-25', '002', 'Pensil', '2', '2500', '5000'),
-> ('B03', '2012-11-25', '001', 'Buku Tulis', '2', '1500', '3000');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> drop table tb_transaksi;
Query OK, 0 rows affected (0.05 sec)
mysql> create table tb_transaksi
-> (kd_transaksi varchar (20) not null primary key,
-> tgl_transaksi date,
-> kd_barang varchar (20),
-> nama_barang varchar (20),
-> qty integer,
-> harga_satuan integer,
-> sub_total integer);
Query OK, 0 rows affected (0.05 sec)
mysql> insert into tb_transaksi value
-> ('B01', '2012-11-26', '003', 'Pulpen', '2', '1000', '2000'),
-> ('B02', '2012-11-25', '002', 'Pensil', '2', '2500', '5000'),
-> ('B03', '2012-11-25', '001', 'Buku Tulis', '2', '1500', '3000');
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select*from tb_transaksi;
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
| kd_transaksi | tgl_transaksi | kd_barang | nama_barang | qty | harga_satuan |
sub_total |
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
| B01 | 2012-11-26 | 003 | Pulpen | 2 | 1000 |
2000 |
| B02 | 2012-11-25 | 002 | Pensil | 2 | 2500 |
5000 |
| B03 | 2012-11-25 | 001 | Buku Tulis | 2 | 1500 |
3000 |
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
3 rows in set (0.00 sec)
mysql> alter table tb_stok rename tb_barang;
Query OK, 0 rows affected (0.02 sec)
mysql> select min(jumlah) from tb_barang;
+-------------+
| min(jumlah) |
+-------------+
| 20 |
+-------------+
1 row in set (0.01 sec)
mysql> select*from tb_transaksi where tgl_transaksi between '2012-11-26' and '20
12-11-25';
Empty set (0.00 sec)
mysql> select sum(sub_total) from tb_transaksi;
+----------------+
| sum(sub_total) |
+----------------+
| 10000 |
+----------------+
1 row in set (0.02 sec)
mysql> alter table tb_barang add kd_supplier varchar (10) first;
Query OK, 5 rows affected (0.16 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select*from tb_barang;
+-------------+-----------+-------------+--------+-------+
| kd_supplier | kd_barang | nama_barang | jumlah | harga |
+-------------+-----------+-------------+--------+-------+
| NULL | 001 | Buku Tulis | 20 | 1500 |
| NULL | 002 | Pensil | 20 | 2500 |
| NULL | 003 | Pulpen | 20 | 1000 |
| NULL | 004 | Penghapus | 20 | 1000 |
| NULL | 005 | Penggaris | 20 | 1000 |
+-------------+-----------+-------------+--------+-------+
5 rows in set (0.00 sec)
mysql> update tb_barang set kd_supplier='S01';
Query OK, 5 rows affected (0.05 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> select*from tb_barang;
+-------------+-----------+-------------+--------+-------+
| kd_supplier | kd_barang | nama_barang | jumlah | harga |
+-------------+-----------+-------------+--------+-------+
| S01 | 001 | Buku Tulis | 20 | 1500 |
| S01 | 002 | Pensil | 20 | 2500 |
| S01 | 003 | Pulpen | 20 | 1000 |
| S01 | 004 | Penghapus | 20 | 1000 |
| S01 | 005 | Penggaris | 20 | 1000 |
+-------------+-----------+-------------+--------+-------+
5 rows in set (0.00 sec)
mysql> select*from tb_transaksi where tgl_transaksi between '2012-11-25' and '20
12-11-26';
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
| kd_transaksi | tgl_transaksi | kd_barang | nama_barang | qty | harga_satuan |
sub_total |
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
| B01 | 2012-11-26 | 003 | Pulpen | 2 | 1000 |
2000 |
| B02 | 2012-11-25 | 002 | Pensil | 2 | 2500 |
5000 |
| B03 | 2012-11-25 | 001 | Buku Tulis | 2 | 1500 |
3000 |
+--------------+---------------+-----------+-------------+------+--------------+
-----------+
3 rows in set (0.00 sec)
mysql> delete from tb_barang where kd_barang='005';
Query OK, 1 row affected (0.05 sec)
mysql> select*from tb_barang;
+-------------+-----------+-------------+--------+-------+
| kd_supplier | kd_barang | nama_barang | jumlah | harga |
+-------------+-----------+-------------+--------+-------+
| S01 | 001 | Buku Tulis | 20 | 1500 |
| S01 | 002 | Pensil | 20 | 2500 |
| S01 | 003 | Pulpen | 20 | 1000 |
| S01 | 004 | Penghapus | 20 | 1000 |
+-------------+-----------+-------------+--------+-------+
4 rows in set (0.00 sec)
mysql> select*from tb_barang where harga>1000 and jumlah>=20;
+-------------+-----------+-------------+--------+-------+
| kd_supplier | kd_barang | nama_barang | jumlah | harga |
+-------------+-----------+-------------+--------+-------+
| S01 | 001 | Buku Tulis | 20 | 1500 |
| S01 | 002 | Pensil | 20 | 2500 |
+-------------+-----------+-------------+--------+-------+
2 rows in set (0.00 sec)
mysql>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>cd\
C:\>cd xampp\
C:\xampp>cd mysql\
C:\xampp\mysql>cd bin\
C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database db_akademik;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_akademik |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.08 sec)
mysql> use db_akademik;
Database changed
mysql> create table tb_mahasiswa
-> (NIM varchar (10) not null primary key,
-> Nama varchar (25),
-> Jenis_kelamin varchar (10),
-> Agama varchar (10),
-> Alamat varchar (50));
Query OK, 0 rows affected (0.11 sec)
mysql> create table tb_mata_kuliah
-> (kd_makul varchar (10) not null primary key,
-> Nama_makul varchar (20),
-> SKS varchar (5),
-> Semester varchar (5),
-> Dosen_Pengampu varchar (25));
Query OK, 0 rows affected (0.03 sec)
mysql> create table tb_dosen
-> No_dosen varchar (10) not null primary key,
-> Nama_dosen varchar (25),
-> Matkul_diampu varchar (20),
-> Gelar varchar (20),
-> Alamat varchar (25));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'No_do
sen varchar (10) not null primary key,
Nama_dosen varchar (25),
Matkul_diam' at line 2
mysql> create table tb_dosen
-> (No_dosen varchar (10) not null primary key,
-> Nama_dosen varchar (25),
-> Matkul_diampu varchar (20),
-> Gelar varchar (20),
-> Alamat varchar (25));
Query OK, 0 rows affected (0.08 sec)
mysql> create table tb_nilai
-> kd_matkul varchar (10) not null primary key,
-> Nama_makul varchar (20),
-> Nama varchar (25),
-> NIM varchar (10),
-> SKS varchar (5),
-> nilai integer;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'kd_ma
tkul varchar (10) not null primary key,
Nama_makul varchar (20),
Nama varch' at line 2
mysql> create table tb_nilai
-> (kd_matkul varchar (10) not null primary key,
-> Nama_makul varchar (20),
-> NIM varchar (10),
-> Nama varchar (25),
-> SKS varchar (5),
-> nilai integer);
Query OK, 0 rows affected (0.05 sec)
mysql> insert into tb_mahasiswa value
-> ('001', 'aaaaa', 'sssss', 'ddddd', 'fffff'),
-> ('002', 'aaaaa', 'sssss', 'ddddd', 'fffff'),
-> ('003', 'aaaaa', 'sssss', 'ddddd', 'fffff'),
-> ('004', 'aaaaa', 'sssss', 'ddddd', 'fffff'),
-> ('005', 'aaaaa', 'sssss', 'ddddd', 'fffff');
Query OK, 5 rows affected (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select*from tb_mahasiswa;
+-----+-------+---------------+-------+--------+
| NIM | Nama | Jenis_kelamin | Agama | Alamat |
+-----+-------+---------------+-------+--------+
| 001 | aaaaa | sssss | ddddd | fffff |
| 002 | aaaaa | sssss | ddddd | fffff |
| 003 | aaaaa | sssss | ddddd | fffff |
| 004 | aaaaa | sssss | ddddd | fffff |
| 005 | aaaaa | sssss | ddddd | fffff |
+-----+-------+---------------+-------+--------+
5 rows in set (0.01 sec)
mysql> delete from tb_mahasiswa;
Query OK, 5 rows affected (0.05 sec)
mysql> select*from tb_mahasiswa;
Empty set (0.00 sec)
mysql> insert into tb_mahasiswa value
-> ('001', 'agus', 'lai-laki', 'islam', 'jogja'),
-> ('002', 'tina', 'perempuan', 'kristen', 'bantul'),
-> ('003', 'susi', 'perempuan', 'islam', 'kulon progo'),
-> ('004', 'joko', 'laki-laki', 'katholik', 'sleman'),
-> ('005', 'toko', 'laki-laki', 'islam', 'sleman');
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into tb_mata_kuliah value
-> ('MK01', 'Basis Data', '3sks', '3', 'Iwan Hartadi'),
-> ('MK02', 'Komunikasi Data', '2sks', '5', 'Danang Nur'),
-> ('MK03', 'ANSI', '2sks', '3', 'Edhy Sutanta'),
-> ('MK04', 'Aljabar', '2sks', '3', 'Ratna'),
-> ('MK05', 'Etika Profesi', '2sks', '5', 'Endar');
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into tb_dosen value
-> ('D001', 'Iwan Hartadi', 'Basis Data', 'ST., Mkom.', 'Jogja'),
-> ('D002', 'Danang Nur', 'Komunikasi Data', 'ST.', 'Sleman'),
-> ('D003', 'Edhy Sutanta', 'ANSI', 'Mkom.', 'Sleman'),
-> ('D004', 'Ratna', 'Aljabar', 'ST.', 'Jogja'),
-> ('D005', 'Endar', 'Etika Profesi', 'ST., MBA', 'Jogja');
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into tb_nilai value
-> ('MK02', 'Komunikasi Data', '003', 'Susi', '2sks', 'A'),
-> ('MK04', 'Aljabar', '002', 'Tina', '2sks', 'A'),
-> ('MK01', 'Basis Data', '001', 'Agus', '3sks', 'A'),
-> ('MK05', 'Etika Profesi', '004', 'Joko', '3sks', 'A'),
-> ('MK03', 'ANSI', '005', 'Toko', '2sks', 'A');
Query OK, 5 rows affected, 5 warnings (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 5
mysql> select*from tb_mahasiswa;
+-----+------+---------------+----------+-------------+
| NIM | Nama | Jenis_kelamin | Agama | Alamat |
+-----+------+---------------+----------+-------------+
| 001 | agus | lai-laki | islam | jogja |
| 002 | tina | perempuan | kristen | bantul |
| 003 | susi | perempuan | islam | kulon progo |
| 004 | joko | laki-laki | katholik | sleman |
| 005 | toko | laki-laki | islam | sleman |
+-----+------+---------------+----------+-------------+
5 rows in set (0.00 sec)
mysql> select*from tb_mata_kuliah;
+----------+-----------------+------+----------+----------------+
| kd_makul | Nama_makul | SKS | Semester | Dosen_Pengampu |
+----------+-----------------+------+----------+----------------+
| MK01 | Basis Data | 3sks | 3 | Iwan Hartadi |
| MK02 | Komunikasi Data | 2sks | 5 | Danang Nur |
| MK03 | ANSI | 2sks | 3 | Edhy Sutanta |
| MK04 | Aljabar | 2sks | 3 | Ratna |
| MK05 | Etika Profesi | 2sks | 5 | Endar |
+----------+-----------------+------+----------+----------------+
5 rows in set (0.00 sec)
mysql> select*from tb_dosen;
+----------+--------------+-----------------+------------+--------+
| No_dosen | Nama_dosen | Matkul_diampu | Gelar | Alamat |
+----------+--------------+-----------------+------------+--------+
| D001 | Iwan Hartadi | Basis Data | ST., Mkom. | Jogja |
| D002 | Danang Nur | Komunikasi Data | ST. | Sleman |
| D003 | Edhy Sutanta | ANSI | Mkom. | Sleman |
| D004 | Ratna | Aljabar | ST. | Jogja |
| D005 | Endar | Etika Profesi | ST., MBA | Jogja |
+----------+--------------+-----------------+------------+--------+
5 rows in set (0.00 sec)
mysql> select*from tb_nilai;
+-----------+-----------------+------+------+------+-------+
| kd_matkul | Nama_makul | NIM | Nama | SKS | nilai |
+-----------+-----------------+------+------+------+-------+
| MK01 | Basis Data | 001 | Agus | 3sks | 0 |
| MK02 | Komunikasi Data | 003 | Susi | 2sks | 0 |
| MK03 | ANSI | 005 | Toko | 2sks | 0 |
| MK04 | Aljabar | 002 | Tina | 2sks | 0 |
| MK05 | Etika Profesi | 004 | Joko | 3sks | 0 |
+-----------+-----------------+------+------+------+-------+
5 rows in set (0.00 sec)
mysql> update tb_nilai set nilai='A';
Query OK, 0 rows affected, 5 warnings (0.05 sec)
Rows matched: 5 Changed: 0 Warnings: 5
mysql> select*from tb_nilai;
+-----------+-----------------+------+------+------+-------+
| kd_matkul | Nama_makul | NIM | Nama | SKS | nilai |
+-----------+-----------------+------+------+------+-------+
| MK01 | Basis Data | 001 | Agus | 3sks | 0 |
| MK02 | Komunikasi Data | 003 | Susi | 2sks | 0 |
| MK03 | ANSI | 005 | Toko | 2sks | 0 |
| MK04 | Aljabar | 002 | Tina | 2sks | 0 |
| MK05 | Etika Profesi | 004 | Joko | 3sks | 0 |
+-----------+-----------------+------+------+------+-------+
5 rows in set (0.00 sec)
mysql> update tb_nilai set nilai='100';
Query OK, 5 rows affected (0.08 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> select*from tb_nilai;
+-----------+-----------------+------+------+------+-------+
| kd_matkul | Nama_makul | NIM | Nama | SKS | nilai |
+-----------+-----------------+------+------+------+-------+
| MK01 | Basis Data | 001 | Agus | 3sks | 100 |
| MK02 | Komunikasi Data | 003 | Susi | 2sks | 100 |
| MK03 | ANSI | 005 | Toko | 2sks | 100 |
| MK04 | Aljabar | 002 | Tina | 2sks | 100 |
| MK05 | Etika Profesi | 004 | Joko | 3sks | 100 |
+-----------+-----------------+------+------+------+-------+
5 rows in set (0.00 sec)
mysql>