Sabtu, 29 November 2014
Perintah Query SQL Membuat Database Penjualan
Tag
GUYS SELAMAT SIANG
GUE MAU SHARING NIH !!
INI KODINGAN QUERY SQL UNTUK MEMBUAT DATABASE PENJUALAN
DI SIMAK YAHH
mysql> use database_penjualan;
Database changed
mysql> create table barang(
-> kode_barang char(12),
-> nama_barang varchar(20),
-> kode_supplier char(6),
-> kode_jenis int(11),
-> stock int(4),
-> kode_satuan char(5),
-> kode_lokasi char(5),
-> harga int(8));
Query OK, 0 rows affected (1.41 sec)
mysql> desc barang;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_barang | char(12) | NO | PRI | | |
| nama_barang | varchar(20) | YES | | NULL | |
| kode_supplier | char(6) | YES | | NULL | |
| kode_jenis | int(11) | YES | | NULL | |
| stock | int(4) | YES | | NULL | |
| kode_satuan | char(5) | YES | | NULL | |
| kode_lokasi | char(5) | YES | | NULL | |
| harga | int(8) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
8 rows in set (0.02 sec)
mysql> create table supplier(
-> kode_supplier char(6),
-> nama_supplier varchar(20),
-> alamat varchar(50),
-> email varchar(20),
-> no_telp varchar(15));
Query OK, 0 rows affected (1.18 sec)
mysql> desc supplier;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_supplier | char(6) | NO | PRI | | |
| nama_supplier | varchar(20) | YES | | NULL | |
| alamat | varchar(50) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
| no_telp | varchar(15) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
5 rows in set (0.03 sec)
mysql> create table customer(
-> kode_customer char(6),
-> nama_customer varchar(20),
-> alamat varchar(50),
-> no_telp varchar(15),
-> email varchar(20));
Query OK, 0 rows affected (1.09 sec)
mysql> desc customer;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_customer | char(6) | NO | PRI | | |
| nama_customer | varchar(20) | YES | | NULL | |
| alamat | varchar(50) | YES | | NULL | |
| no_telp | varchar(15) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
5 rows in set (0.02 sec)
mysql> create table jenis(
-> kode_jenis int null auto_increment key,
-> nama_jenis varchar(10));
Query OK, 0 rows affected (0.28 sec)
mysql> desc jenis;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| kode_jenis | int(11) | NO | PRI | NULL | auto_increment |
| nama_jenis | varchar(10) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
2 rows in set (0.02 sec)
mysql> create table satuan(
-> kode_satuan char(5),
-> nama_satuan varchar(10));
Query OK, 0 rows affected (0.33 sec)
mysql> desc satuan;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| kode_satuan | char(5) | NO | PRI | | |
| nama_satuan | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> create table lokasi(
-> kode_lokasi char(5),
-> nama_lokasi varchar(10));
Query OK, 0 rows affected (0.07 sec)
mysql> desc lokasi;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| kode_lokasi | char(5) | NO | PRI | | |
| nama_lokasi | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
mysql> create table transaksi(
-> kode_transaksi varchar(15),
-> tanggal date,
-> jam time,
-> kode_customer char(6),
-> total int(10),
-> kode_petugas char(10));
Query OK, 0 rows affected (0.11 sec)
mysql> desc transaksi;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| kode_transaksi | varchar(15) | NO | PRI | | |
| tanggal | date | YES | | NULL | |
| jam | time | YES | | NULL | |
| kode_customer | char(6) | YES | | NULL | |
| total | int(10) | YES | | NULL | |
| kode_petugas | char(10) | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
6 rows in set (0.01 sec)
mysql> create table detail_transaksi(
-> kode_detail int null auto_increment key,
-> kode_transaksi varchar(15),
-> kode_barang char(12),
-> harga int(10),
-> qty int(10),
-> sub_total int(10)
-> );
Query OK, 0 rows affected (0.11 sec)
mysql> desc detail_transaksi;
+----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+----------------+
| kode_detail | int(11) | NO | PRI | NULL | auto_increment |
| kode_transaksi | varchar(15) | YES | | NULL | |
| kode_barang | char(12) | YES | | NULL | |
| harga | int(10) | YES | | NULL | |
| qty | int(10) | YES | | NULL | |
| sub_total | int(10) | YES | | NULL | |
+----------------+-------------+------+-----+---------+----------------+
6 rows in set (0.02 sec)
mysql> create table petugas(
-> kode_petugas int null auto_increment key,
-> nama_petugas varchar(20),
-> alamat varchar(50),
-> no_telp varchar(15),
-> password varchar(9));
Query OK, 0 rows affected (0.10 sec)
mysql> desc petugas;
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| kode_petugas | int(11) | NO | PRI | NULL | auto_increment |
| nama_petugas | varchar(20) | YES | | NULL | |
| alamat | varchar(50) | YES | | NULL | |
| no_telp | varchar(15) | YES | | NULL | |
| password | varchar(9) | YES | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
5 rows in set (0.64 sec)
Hasil tabel yang sudah di buat
mysql> show tables;
+------------------------------+
| Tables_in_database_penjualan |
+------------------------------+
| barang |
| customer |
| detail_transaksi |
| jenis |
| lokasi |
| petugas |
| satuan |
| supplier |
| transaksi |
+------------------------------+
9 rows in set (0.29 sec)
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar