PERINTAH QUERY UNTUK MENAMBAHKAN ISI DATA DALAM TABEL-TABEL

PERINTAH QUERY INSERT DATA PADA TABEL-TABEL (DI CMD)

Microsoft Windows [Version 6.1.7600]

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\EDI SANTOSO>cd/xampp/mysql/bin


C:\xampp\mysql\bin>mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.5.8 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> use database_penjualan;

Database changed
mysql> show tables;
+-------------------------------------+
| Tables_in_database_penjualan  |
+-------------------------------------+
| barang                                        |
| customer                                    |
| detail_transaksi                          |
| jenis                                           |
| lokasi                                         |
| petugas                                      |
| satuan                                        |
| supplier                                     |
| transaksi                                    |
+-------------------------------------+
9 rows in set (0.00 sec)


mysql> desc jenis;

+-------------+---------------+-------+-----+----------+-------------------+
| Field           | Type            | Null  | Key | Default | Extra                  |
+-------------+---------------+-------+-----+----------+-------------------+
| kode_jenis  | int(11)         | NO    | PRI | NULL   | auto_increment |
| nama_jenis | varchar(25) | YES   |        | NULL   |                           |
+-------------+---------------+-------+-----+----------+-------------------+
2 rows in set (0.02 sec)

mysql> insert into jenis (kode_jenis,nama_jenis) value

    -> (null,'deterjen');
Query OK, 1 row affected (0.11 sec)

mysql> insert into jenis values (null,'sabun mandi');

Query OK, 1 row affected, 1 warning (0.03 sec)

mysql> insert into jenis values (null,'rokok');

Query OK, 1 row affected (0.06 sec)

mysql> insert into jenis values (null,'minyak goreng');

Query OK, 1 row affected (0.05 sec)

mysql> insert into jenis values (null,'shampo');

Query OK, 1 row affected (0.06 sec)


mysql> select * from jenis;

+-------------+-------------------+
| kode_jenis | nama_jenis        |
+-------------+-------------------+
|          1        | deterjen            |
|          2        | sabun mandi    |
|          3        | rokok               |
|          4        | minyak goreng|
|          5        | shampo            |
+-------------+------------------+
5 rows in set (0.00 sec)


mysql> desc lokasi;

+---------------+--------------+-------+------+----------+-------+
| Field             | Type           | Null   | Key | Default  | Extra |
+---------------+--------------+-------+------+----------+-------+
| kode_lokasi  | char(5)        | NO    | PRI | NULL    |           |
| nama_lokasi | varchar(10) | YES  |         | NULL    |          |
+---------------+--------------+-------+------+----------+-------+
2 rows in set (0.00 sec)

mysql> insert into lokasi values ('l01','rak A1');

Query OK, 1 row affected (0.06 sec)

mysql> insert into lokasi values ('l02','rak A2');

Query OK, 1 row affected (0.05 sec)

mysql> insert into lokasi values ('l03','rak A3');

Query OK, 1 row affected (0.06 sec)

mysql> insert into lokasi values ('l04','rak A4');

Query OK, 1 row affected (0.06 sec)

mysql> insert into lokasi values ('l05','rak A5');

Query OK, 1 row affected (0.06 sec)


mysql> select * from lokasi;

+--------------+----------------+
| kode_lokasi | nama_lokasi |
+--------------+----------------+
| l01              | rak A1           |
| l02              | rak A2           |
| l03              | rak A3           |
| l04              | rak A4           |
| l05              | rak A5           |
+-------------+-----------------+
5 rows in set (0.00 sec)


mysql> desc satuan;

+----------------+---------------+------+-----+----------+-------+
| Field               | Type           | Null  | Key | Default | Extra |
+----------------+---------------+------+-----+----------+-------+
| kode_satuan   | char(5)        | NO   | PRI | NULL   |           |
| nama_satuan  | varchar(10) | YES |         | NULL  |            |
+----------------+--------------+-------+-----+---------+--------+
2 rows in set (0.02 sec)

mysql> insert into satuan values ('s01','kilogram');

Query OK, 1 row affected (0.06 sec)

mysql> insert into satuan values ('s02','gram');

Query OK, 1 row affected (0.03 sec)

mysql> insert into satuan values ('s03','dus');

Query OK, 1 row affected (0.06 sec)

mysql> insert into satuan values ('s04','liter');

Query OK, 1 row affected (0.36 sec)

mysql> insert into satuan values ('s05','sachet');

Query OK, 1 row affected (0.06 sec)


mysql> select * from satuan;

+---------------+----------------+
| kode_satuan | nama_satuan |
+---------------+----------------+
| s01                | kilogram       |
| s02                | gram             |
| s03                | dus                |
| s04                | liter               |
| s05                | sachet            |
+---------------+----------------+
5 rows in set (0.00 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(40) | YES  |        | NULL    |           |
| no_telp             | varchar(15) | YES  |        | NULL    |           |
+------------------+--------------+-------+-----+-----------+-------+
5 rows in set (0.00 sec)

mysql> insert into supplier values

     > ('sp01','pt.deterjen nusantara','jakarta','deterjen.01@yahoo.com','021777xxxxxx');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> insert into supplier values

     > ('sp02','pt.lifeboy global','jakarta','lifeboy.02@yahoo.com','021232xxxxxx');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> insert into supplier values

     > ('sp03','pt.djarum indonesia','banten','djarum.03@gmail.com','021999xxxxxx');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> insert into supplier values

     > ('sp04','pt.bimoli nusantara','jakarta','bimoli.04@gmail.com','021222xxxxxx');
Query OK, 1 row affected, 1 warning (0.06 sec)

mysql> insert into supplier values

     > ('sp05','pt.clear indonesia','indramayu','clear.05@gmail.com','021234xxxxxx');
Query OK, 1 row affected, 1 warning (0.06 sec)


mysql> select * from supplier;

+---------------+----------------------+-----------+-----------------------+--------------+
| kode_supplier | nama_supplier        | alamat    | email                 | no_telp      |
+---------------+----------------------+-----------+-----------------------+--------------+
| sp01          | pt.deterjen nusantar | jakarta   | deterjen.01@yahoo.com | 021777xxxxxx |
| sp02          | pt.lifeboy global    | jakarta   | lifeboy.02@yahoo.com  | 021232xxxxxx |
| sp03          | pt.djarum indonesia  | banten    | djarum.03@gmail.com   | 021999xxxxxx |
| sp04          | pt.bimoli nusantara  | jakarta   | bimoli.04@gmail.com   | 021222xxxxxx |
| sp05          | pt.clear indonesia   | indramayu | clear.05@gmail.com    | 021234xxxxxx |
+---------------+----------------------+-----------+-----------------------+--------------+
5 rows in set (0.00 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(30) | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
5 rows in set (0.05 sec)

mysql> insert into customer value

    -> ('cs01','m.edi santoso','indramayu','087726xxxxxx','muhamad.edi25@gmail.com');
Query OK, 1 row affected (0.06 sec)

mysql> insert into customer value

    -> ('cs02','tofik survey','cikarang','081234xxxxxx','tofik.surv@gmail.com');
Query OK, 1 row affected (0.06 sec)

mysql> insert into customer value

    -> ('cs03','erni nurzhaety','indramayu','087818xxxxxx','erni.zha07@gmail.com');
Query OK, 1 row affected (0.06 sec)

mysql> insert into customer value

    -> ('cs04','lina karlina','jakarta','085678xxxxxx','lina.09@yahoo.com');
Query OK, 1 row affected (0.05 sec)

mysql> insert into customer value

    -> ('cs05','mia miun','cikarang','089876xxxxxx','mia.miun23@gmail.com');
Query OK, 1 row affected (0.05 sec)


mysql> select * from customer;

+---------------+----------------+-----------+--------------+-------------------------+
| kode_customer | nama_customer  | alamat    | no_telp      | email                   |
+---------------+----------------+-----------+--------------+-------------------------+
| cs01          | m.edi santoso  | indramayu | 087726xxxxxx | muhamad.edi25@gmail.com |
| cs02          | tofik survey   | cikarang  | 081234xxxxxx | tofik.surv@gmail.com    |
| cs03          | erni nurzhaety | indramayu | 087818xxxxxx | erni.zha07@gmail.com    |
| cs04          | lina karlina   | jakarta   | 085678xxxxxx | lina.09@yahoo.com       |
| cs05          | mia miun       | cikarang  | 089876xxxxxx | mia.miun23@gmail.com    |
+---------------+----------------+-----------+--------------+-------------------------+
5 rows in set (0.00 sec)


mysql> desc petugas;

+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| kode_petugas | char(10)    | NO   | PRI |         |       |
| 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.05 sec)

mysql> insert into petugas value

    -> ('p001','edi zaky','cikarang','087876xxxxxx','pt011');
Query OK, 1 row affected (0.05 sec)

mysql> insert into petugas value

    -> ('p002','lina.karlina','indramayu','087818xxxxxx','pt012');
Query OK, 1 row affected (0.06 sec)

mysql> insert into petugas value

    -> ('p003','andre wiliam','cikarang','081234xxxxxx','pt013');
Query OK, 1 row affected (0.06 sec)

mysql> insert into petugas value

    -> ('p004','yunita fitri','jakarta','085678xxxxxx','pt014');
Query OK, 1 row affected (0.03 sec)

mysql> insert into petugas value

    -> ('p005','erni nurzhaety','indramayu','088678xxxxxx','pt015');
Query OK, 1 row affected (0.06 sec)


mysql> select*from petugas;

+--------------+----------------+-----------+--------------+----------+
| kode_petugas | nama_petugas   | alamat    | no_telp      | password |
+--------------+----------------+-----------+--------------+----------+
| p001         | edi zaky       | cikarang  | 087876xxxxxx | pt011    |
| p002         | lina.karlina   | indramayu | 087818xxxxxx | pt012    |
| p003         | andre wiliam   | cikarang  | 081234xxxxxx | pt013    |
| p004         | yunita fitri   | jakarta   | 085678xxxxxx | pt014    |
| p005         | erni nurzhaety | indramayu | 088678xxxxxx | pt015    |
+--------------+----------------+-----------+--------------+----------+
5 rows in set (0.00 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  | MUL | NULL    |       |
| kode_jenis    | int(11)     | YES  | MUL | NULL    |       |
| stock         | int(4)      | YES  |     | NULL    |       |
| kode_satuan   | char(5)     | YES  | MUL | NULL    |       |
| kode_lokasi   | char(5)     | YES  | MUL | NULL    |       |
| harga         | int(8)      | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
8 rows in set (0.03 sec)

mysql> insert into barang value

    -> ('br01','rinso','sp01','1','200','s01','l01','2000');
Query OK, 1 row affected (0.05 sec)

mysql> insert into barang value

    -> ('br02','lifeboy','sp02','2','300','s02','l02','3000');
Query OK, 1 row affected (0.05 sec)

mysql> insert into barang value

    -> ('br03','sampoerna mild','sp03','3','700','s03','l03','15000');
Query OK, 1 row affected (0.06 sec)

mysql> insert into barang value

    -> ('br04','tropical','sp04','4','500','s04','l04','20000');
Query OK, 1 row affected (0.06 sec)

mysql> insert into barang value

    -> ('br05','clear','sp05','5','400','s05','l05','2000');
Query OK, 1 row affected (0.03 sec)


mysql> select * from barang;

+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang    | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br01        | rinso          | sp01          |          1 |   200 | s01         | l01         |  2000 |
| br02        | lifeboy        | sp02          |          2 |   300 | s02         | l02         |  3000 |
| br03        | sampoerna mild | sp03          |          3 |   700 | s03         | l03         | 15000 |
| br04        | tropical       | sp04          |          4 |   500 | s04         | l04         | 20000 |
| br05        | clear          | sp05          |          5 |   400 | s05         | l05         |  2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
5 rows in set (0.00 sec)


mysql> desc transaksi;

+----------------+----------+------+-----+---------+-------+
| Field          | Type     | Null | Key | Default | Extra |
+----------------+----------+------+-----+---------+-------+
| kode_transaksi | char(15) | NO   | PRI | NULL    |       |
| tanggal        | date     | YES  |     | NULL    |       |
| jam            | time     | YES  |     | NULL    |       |
| kode_customer  | char(6)  | YES  | MUL | NULL    |       |
| total          | int(10)  | YES  |     | NULL    |       |
| kode_petugas   | char(10) | YES  | MUL | NULL    |       |
+----------------+----------+------+-----+---------+-------+
6 rows in set (0.02 sec)

mysql> insert into transaksi values

    -> ('tr01','2014-07-20','08:45','cs01','100000','p001');
Query OK, 1 row affected (0.05 sec)

mysql> insert into transaksi values

    -> ('tr02','2014-08-15','20:10','cs02','200000','p002');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> insert into transaksi values

    -> ('tr03','2014-09-23','09:30','cs03','900000','p003');
Query OK, 1 row affected (0.06 sec)

mysql> insert into transaksi values

    -> ('tr04','2014-09-25','12:30','cs04','800000','p004');
Query OK, 1 row affected (0.05 sec)

mysql> insert into transaksi values

    -> ('tr05','2014-08-17','18:30','cs05','100000','p005');
Query OK, 1 row affected (0.05 sec)


mysql> select * from transaksi;

+----------------+------------+----------+---------------+--------+--------------+
| kode_transaksi | tanggal    | jam      | kode_customer | total  | kode_petugas |
+----------------+------------+----------+---------------+--------+--------------+
| tr01           | 2014-07-20 | 08:45:00 | cs01          | 100000 | p001         |
| tr02           | 2014-08-15 | 20:10:00 | cs02          | 200000 | p002         |
| tr03           | 2014-09-23 | 09:30:00 | cs03          | 900000 | p003         |
| tr04           | 2014-09-25 | 12:30:00 | cs04          | 800000 | p004         |
| tr05           | 2014-08-17 | 18:30:00 | cs05          | 100000 | p005         |
+----------------+------------+----------+---------------+--------+--------------+
5 rows in set (0.00 sec)


mysql> desc detail_transaksi;

+----------------+----------+------+-----+---------+----------------+
| Field          | Type     | Null | Key | Default | Extra          |
+----------------+----------+------+-----+---------+----------------+
| kode_detail    | int(11)  | NO   | PRI | NULL    | auto_increment |
| kode_transaksi | char(15) | YES  | MUL | NULL    |                |
| kode_barang    | char(12) | YES  | MUL | NULL    |                |
| harga          | int(10)  | YES  |     | NULL    |                |
| qty            | int(4)   | YES  |     | NULL    |                |
| sub_total      | int(10)  | YES  |     | NULL    |                |
+----------------+----------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

mysql> insert into detail_transaksi value

    -> ('kd01','tr01','br01','2000','200','400000');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> insert into detail_transaksi value

    -> ('kd02','tr02','br02','3000','300','900000');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> insert into detail_transaksi value

    -> ('kd03','tr03','br03','15000','700','10500000');
Query OK, 1 row affected, 2 warnings (0.06 sec)

mysql> insert into detail_transaksi value

    -> ('kd04','tr04','br04','20000','500','10000000');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> insert into detail_transaksi value

    -> ('kd05','tr05','br05','2000','400','800000');
Query OK, 1 row affected, 1 warning (0.05 sec)


mysql> select * from detail_transaksi;

+-------------+----------------+-------------+-------+------+-----------+
| kode_detail | kode_transaksi | kode_barang | harga | qty  | sub_total |
+-------------+----------------+-------------+-------+------+-----------+
|           1 | tr01           | br01        |  2000 |  200 |    400000 |
|           2 | tr02           | br02        |  3000 |  300 |    900000 |
|           3 | tr03           | br03        | 15000 |  700 |  10500000 |
|           4 | tr04           | br04        | 20000 |  500 |  10000000 |
|           5 | tr05           | br05        |  2000 |  400 |    800000 |
+-------------+----------------+-------------+-------+------+-----------+
5 rows in set (0.00 sec)

Komentar

Postingan populer dari blog ini

PERINTAH FUNGSI MAX, MIN, COUNT, SUM, & AVG

QUERY DATA BASE

MODEL DATA BERBASIS OBJEK