Nama : Iffan Marta Alfallah
Kelas : SI3F
NIM : 17-141-0082
MK : Data Base
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\lenovo>cd/
C:\>cd xampp
C:\xampp>cd mysql
C:\xampp\mysql>cd bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.21-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| db_akademik |
| db_rs |
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
7 rows in set (0.38 sec)
MariaDB [(none)]> create database DB_PENJUALAN;
Query OK, 1 row affected (0.04 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| db_akademik |
| db_penjualan |
| db_rs |
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
8 rows in set (0.00 sec)
MariaDB [(none)]> use db_penjualan;
Database changed
MariaDB [db_penjualan]> create table barang
-> (kdbarang varchar(5) not null primary key,
-> nm_barang varchar(30),
-> harga varchar(10),
-> satuan varchar(10)
-> );
Query OK, 0 rows affected (0.47 sec)
MariaDB [db_penjualan]> create table pembeli
-> (kdpembeli varchar(5) not null primary key,
-> nm_pembeli varchar(30),
-> alamat varchar(30)
-> );
Query OK, 0 rows affected (0.39 sec)
MariaDB [db_penjualan]> create table transaksi
-> (no_transaksi varchar(5) not null primary key,
-> kdbarang varchar(5),
-> kdpembeli varchar(5),
-> jmlh_barang varchar(10),
-> total_byr varchar(10)
-> );
Query OK, 0 rows affected (0.39 sec)
MariaDB [db_penjualan]> desc barang;
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| kdbarang | varchar(5) | NO | PRI | NULL | |
| nm_barang | varchar(30) | YES | | NULL | |
| harga | varchar(10) | YES | | NULL | |
| satuan | varchar(10) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.10 sec)
MariaDB [db_penjualan]> desc pembeli;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| kdpembeli | varchar(5) | NO | PRI | NULL | |
| nm_pembeli | varchar(30) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
3 rows in set (0.04 sec)
MariaDB [db_penjualan]> desc transaksi;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| no_transaksi | varchar(5) | NO | PRI | NULL | |
| kdbarang | varchar(5) | YES | | NULL | |
| kdpembeli | varchar(5) | YES | | NULL | |
| jmlh_barang | varchar(10) | YES | | NULL | |
| total_byr | varchar(10) | YES | | NULL | |
+--------------+-------------+------+-----+---------+-------+
5 rows in set (0.04 sec)
MariaDB [db_penjualan]> insert into barang
-> values('0001','Laptop','2.000.000','1');
zQuery OK, 1 row affected (0.07 sec)
MariaDB [db_penjualan]> insert into pembeli
-> values('0011','Iffan Marta Alfallah','Plaju');
Query OK, 1 row affected (1.24 sec)
MariaDB [db_penjualan]> insert into transaksi
-> values('1111','0001','0011','1','2.000.000');
Query OK, 1 row affected (0.04 sec)
MariaDB [db_penjualan]> select * from barang;
+----------+-----------+-----------+--------+
| kdbarang | nm_barang | harga | satuan |
+----------+-----------+-----------+--------+
| 0001 | Laptop | 2.000.000 | 1 |
+----------+-----------+-----------+--------+
1 row in set (0.00 sec)
MariaDB [db_penjualan]> select * from pembeli;
+-----------+----------------------+--------+
| kdpembeli | nm_pembeli | alamat |
+-----------+----------------------+--------+
| 0011 | Iffan Marta Alfallah | Plaju |
+-----------+----------------------+--------+
1 row in set (0.00 sec)
MariaDB [db_penjualan]> select * from transaksi;
+--------------+----------+-----------+-------------+-----------+
| no_transaksi | kdbarang | kdpembeli | jmlh_barang | total_byr |
+--------------+----------+-----------+-------------+-----------+
| 1111 | 0001 | 0011 | 1 | 2.000.000 |
+--------------+----------+-----------+-------------+-----------+
1 row in set (0.00 sec)
MariaDB [db_penjualan]> select
barang.harga,transaksi.no_transaksi,transaksi.jmlh_barang,transaksi.total_byr
-> from barang,transaksi
-> where
-> barang.kdbarang=transaksi.no_transaksi;
Empty set (0.03 sec)
MariaDB [db_penjualan]> select * from barang,pembeli,transaksi;
+----------+-----------+-----------+--------+-----------+----------------------
+--------+--------------+----------+-----------+-------------+-----------+
| kdbarang | nm_barang | harga | satuan | kdpembeli | nm_pembeli |
alamat | no_transaksi | kdbarang | kdpembeli | jmlh_barang | total_byr |
+----------+-----------+-----------+--------+-----------+----------------------
+--------+--------------+----------+-----------+-------------+-----------+
| 0001 | Laptop | 2.000.000 | 1 | 0011 | Iffan Marta Alfallah |
Plaju | 1111 | 0001 | 0011 | 1 | 2.000.000 |
+----------+-----------+-----------+--------+-----------+----------------------
+--------+--------------+----------+-----------+-------------+-----------+
1 row in set (0.00 sec)