Praktikum 1
Enter password:
*******
Welcome to the
MySQL monitor. Commands end with ; or
\g.
Your MySQL
connection id is 1
Server version:
5.5.30 MySQL Community Server (GPL)
Copyright (c)
2000, 2013, 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> show
databases;
+--------------------+
| Database |
+--------------------+
|
information_schema |
| mysql |
|
performance_schema |
| test |
+--------------------+
4 rows in set
(0.02 sec)
mysql> create
database lab4;
Query OK, 1 row
affected (0.00 sec)
mysql> show
databases;
+--------------------+
| Database |
+--------------------+
|
information_schema |
| lab4 |
| mysql |
|
performance_schema |
| test |
+--------------------+
5 rows in set
(0.00 sec)
mysql> use
lab4;
Database changed
mysql> create
table t_mhs(nim varchar(10), nama_mhs varchar(50), alamat varchar(
50), no_telp
varchar(12));
Query OK, 0 rows
affected (0.61 sec)
mysql> desc
t_mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | varchar(10) | YES | |
NULL | |
| nama_mhs |
varchar(50) | YES | | NULL
| |
| alamat | varchar(50) | YES | |
NULL | |
| no_telp | varchar(12) | YES | |
NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set
(0.06 sec)
mysql> insert
into t_mhs values('131052038', 'Efi', 'Papringan', '085233312188')
;
Query OK, 1 row
affected (0.17 sec)
mysql>
select*from t_mhs;
+-----------+----------+-----------+--------------+
| nim | nama_mhs | alamat | no_telp |
+-----------+----------+-----------+--------------+
| 131052038 |
Efi | Papringan | 085233312188 |
+-----------+----------+-----------+--------------+
1 row in set
(0.06 sec)
mysql> load
data local infile 'D://KULIAH AKPRIND/data.txt' into table t_mhs;
Query OK, 5 rows
affected, 5 warnings (0.13 sec)
Records: 5 Deleted: 0
Skipped: 0 Warnings: 5
mysql>
select*from t_mhs;
+-----------+----------+------------+--------------+
| nim | nama_mhs | alamat | no_telp |
+-----------+----------+------------+--------------+
| 131052038 |
Efi | Papringan | 085233312188 |
| nim | nama_mhs | alamat_mhs | no_telp |
| 131052038 |
Efi | Papringan | 085233312188 |
| 131052132 |
Fina | Jogja | 081337654321 |
| 131052035 |
Star | Gejayan | 089612343243 |
| 131052039 |
Riska | Mrican | 081235405768 |
+-----------+----------+------------+--------------+
6 rows in set
(0.00 sec)
mysql> create
table mat_kul(id_matkul varchar(10), nama_matkul varchar(50), sks
int(1), semester
int(1), dosen varchar(10));
Query OK, 0 rows
affected (0.20 sec)
mysql> desc
mat_kul;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| id_matkul | varchar(10) | YES | |
NULL | |
| nama_matkul |
varchar(50) | YES | | NULL
| |
| sks | int(1) | YES
| | NULL |
|
| semester | int(1) | YES
| | NULL |
|
| dosen | varchar(10) | YES | |
NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set
(0.05 sec)
mysql> show
tables;
+----------------+
| Tables_in_lab4
|
+----------------+
| mat_kul |
| t_mhs |
+----------------+
2 rows in set
(0.06 sec)
mysql> drop
table mat_kul;
Query OK, 0 rows
affected (0.22 sec)
mysql> show
tables;
+----------------+
| Tables_in_lab4
|
+----------------+
| t_mhs |
+----------------+
1 row in set
(0.00 sec)
mysql> create
database coba;
Query OK, 1 row
affected (0.00 sec)
mysql> show
databases;
+--------------------+
| Database |
+--------------------+
| information_schema
|
| coba |
| lab4 |
| mysql |
|
performance_schema |
| test |
+--------------------+
6 rows in set
(0.00 sec)
mysql> drop
database coba;
Query OK, 0 rows
affected (0.16 sec)
mysql> show
databases;
+--------------------+
| Database |
+--------------------+
|
information_schema |
| lab4 |
| mysql |
|
performance_schema |
| test |
+--------------------+
5 rows in set
(0.02 sec)
Praktikum 2
Enter password:
*******
Welcome to the
MySQL monitor. Commands end with ; or
\g.
Your MySQL
connection id is 2
Server version:
5.5.30 MySQL Community Server (GPL)
Copyright (c)
2000, 2013, 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> show
databases;
+--------------------+
| Database |
+--------------------+
|
information_schema |
| lab4 |
| mysql |
| part2 |
|
performance_schema |
| test |
+--------------------+
6 rows in set
(0.00 sec)
mysql> use
part2;
Database changed
mysql> create
table t_pegawai(id_peg varchar(8) primary key, nama_peg varchar(50
), alamat_peg
varchar(50));
Query OK, 0 rows
affected (0.19 sec)
mysql> desc
t_pegawai;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| id_peg | varchar(8) | NO
| PRI | NULL | |
| nama_peg | varchar(50) | YES | |
NULL | |
| alamat_peg |
varchar(50) | YES | | NULL
| |
+------------+-------------+------+-----+---------+-------+
3 rows in set
(0.05 sec)
mysql> insert
into t_pegawai values('H-001', 'Efi', 'Papringan');
Query OK, 1 row
affected (0.09 sec)
mysql> insert
into t_pegawai values('H-002', 'Star', 'Jogja');
Query OK, 1 row
affected (0.08 sec)
mysql>
select*from t_pegawai;
+--------+----------+------------+
| id_peg |
nama_peg | alamat_peg |
+--------+----------+------------+
| H-001 | Efi
| Papringan |
| H-002 | Star
| Jogja |
+--------+----------+------------+
2 rows in set
(0.00 sec)
mysql> create
table t_parkir(id_parkir varchar(5) primary key, plat_no varchar(1
2), merk
varchar(10), unique(plat_no));
Query OK, 0 rows
affected (0.27 sec)
mysql> desc
t_parkir;
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| id_parkir |
varchar(5) | NO | PRI | NULL |
|
| plat_no | varchar(12) | YES | UNI | NULL |
|
| merk | varchar(10) | YES | |
NULL | |
+-----------+-------------+------+-----+---------+-------+
3 rows in set
(0.01 sec)
mysql> insert
into t_parkir values('11001', 'AB-6083-JZ', 'HONDA');
Query OK, 1 row
affected (0.42 sec)
mysql> insert
into t_parkir values('11002', 'AB-3077-YZ', 'YAMAHA');
Query OK, 1 row
affected (0.08 sec)
mysql>
select*from t_parkir;
+-----------+------------+--------+
| id_parkir |
plat_no | merk |
+-----------+------------+--------+
| 11001 | AB-6083-JZ | HONDA |
| 11002 | AB-3077-YZ | YAMAHA |
+-----------+------------+--------+
2 rows in set
(0.00 sec)
mysql> show
tables;
+-----------------+
| Tables_in_part2
|
+-----------------+
| t_parkir |
| t_pegawai |
+-----------------+
2 rows in set
(0.00 sec)
mysql> create
table if not exists t_pegawai(id_peg varchar(8) primary key, nama_
peg varchar(50),
alamat_peg varchar(50));
Query OK, 0 rows
affected, 1 warning (0.00 sec)
mysql>
select*from t_parkir;
+-----------+------------+--------+
| id_parkir |
plat_no | merk |
+-----------+------------+--------+
| 11001 | AB-6083-JZ | HONDA |
| 11002 | AB-3077-YZ | YAMAHA |
+-----------+------------+--------+
2 rows in set
(0.00 sec)
mysql> create
table t_parkir_copy as select*from t_parkir;
Query OK, 2 rows
affected (0.22 sec)
Records: 2 Duplicates: 0
Warnings: 0
mysql>
select*from t_parkir_copy;
+-----------+------------+--------+
| id_parkir |
plat_no | merk |
+-----------+------------+--------+
| 11001 | AB-6083-JZ | HONDA |
| 11002 | AB-3077-YZ | YAMAHA |
+-----------+------------+--------+
2 rows in set
(0.00 sec)
Enter password:
*******
Welcome to the
MySQL monitor. Commands end with ; or
\g.
Your MySQL
connection id is 3
Server version:
5.5.30 MySQL Community Server (GPL)
Copyright (c)
2000, 2013, 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
part2;
Database changed
mysql>
select*from t_temporary;
ERROR 1146
(42S02): Table 'part2.t_temporary' doesn't exist
mysql> create
table t_mobil(id_mobil varchar(8) primary key, type varchar(20));
Query OK, 0 rows
affected (0.27 sec)
mysql> desc
t_mobil;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id_mobil |
varchar(8) | NO | PRI | NULL |
|
| type | varchar(20) | YES | |
NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set
(0.00 sec)
mysql> insert
into t_mobil values('HON-01','JAZZ');
Query OK, 1 row
affected (0.06 sec)
mysql> insert
into t_mobil values('TOY-01','AVANZA');
Query OK, 1 row
affected (0.08 sec)
mysql> insert
into t_mobil values('TOY-02','INNOVA');
Query OK, 1 row
affected (0.12 sec)
mysql>
select*from t_mobil;
+----------+--------+
| id_mobil |
type |
+----------+--------+
| HON-01 | JAZZ
|
| TOY-01 | AVANZA |
| TOY-02 | INNOVA |
+----------+--------+
3 rows in set
(0.00 sec)
mysql> create
table t_stok(id_stok varchar(8) primary key, id_mobil varchar(8),
stok int(5),
foreign key(id_mobil) references t_mobil(id_mobil));
Query OK, 0 rows
affected (0.17 sec)
mysql> desc
t_stok;
+----------+------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+----------+------------+------+-----+---------+-------+
| id_stok | varchar(8) | NO | PRI | NULL
| |
| id_mobil |
varchar(8) | YES | MUL | NULL |
|
| stok | int(5) | YES
| | NULL |
|
+----------+------------+------+-----+---------+-------+
3 rows in set
(0.00 sec)
mysql> insert
into t_stok values('ST-002','TOY-01','1000');
Query OK, 1 row
affected (0.11 sec)
mysql> insert
into t_stok values('ST-001','TOY-02','521');
Query OK, 1 row
affected (0.13 sec)
mysql> insert
into t_stok values('ST-003','HON-01','875');
Query OK, 1 row
affected (0.08 sec)
mysql>
select*from t_stok;
+---------+----------+------+
| id_stok |
id_mobil | stok |
+---------+----------+------+
| ST-001 | TOY-02
| 521 |
| ST-002 | TOY-01
| 1000 |
| ST-003 | HON-01
| 875 |
+---------+----------+------+
3 rows in set
(0.00 sec)