0% found this document useful (0 votes)
37 views8 pages

Tugas Apl Basis Data 2

The document shows the steps of connecting to a MariaDB database and exploring the tables and data. It connects to the db_perpusweb database and describes the tables, then selects and inserts data.

Uploaded by

febriana ida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views8 pages

Tugas Apl Basis Data 2

The document shows the steps of connecting to a MariaDB database and exploring the tables and data. It connects to the db_perpusweb database and describes the tables, then selects and inserts data.

Uploaded by

febriana ida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Microsoft Windows [Version 10.0.19045.

2728]
(c) Microsoft Corporation. All rights reserved.

C:\Users\USER>cd c:\xampp\mysql\bin

c:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.27-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, 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_latih_ddl |
| db_latihan_dml |
| db_lthn_dml |
| db_perpusweb |
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| wordpress_db |
+--------------------+
10 rows in set (0.001 sec)

MariaDB [(none)]> use db_perpusweb;


Database changed
MariaDB [db_perpusweb]> show tables;
+------------------------+
| Tables_in_db_perpusweb |
+------------------------+
| admin |
| anggota |
| buku |
| detail_pinjam |
| katalog_buku |
| peminjam |
+------------------------+
6 rows in set (0.001 sec)

MariaDB [db_perpusweb]> desc admin;


+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id_admin | int(5) | NO | PRI | NULL | auto_increment |
| username | varchar(25) | NO | | NULL | |
| password | varchar(35) | NO | | NULL | |
+----------+-------------+------+-----+---------+----------------+
3 rows in set (0.015 sec)

MariaDB [db_perpusweb]> desc anggota;


+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id_anggota | int(5) | NO | PRI | NULL | auto_increment |
| nama | varchar(45) | NO | | NULL | |
| no_tlpn | varchar(15) | NO | | NULL | |
| alamat | varchar(50) | NO | | NULL | |
| email | varchar(30) | NO | | NULL | |
| password | varchar(35) | NO | | NULL | |
+------------+-------------+------+-----+---------+----------------+
6 rows in set (0.014 sec)

MariaDB [db_perpusweb]> desc buku;


+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id_buku | int(5) | NO | PRI | NULL | auto_increment |
| id_katalog | int(5) | NO | | NULL | |
| judul_buku | varchar(50) | NO | | NULL | |
| pengarang | varchar(35) | NO | | NULL | |
| thn_terbit | date | NO | | NULL | |
| penerbit | varchar(50) | NO | | NULL | |
+------------+-------------+------+-----+---------+----------------+
6 rows in set (0.012 sec)

MariaDB [db_perpusweb]> desc detail_pinjam;


+------------------+---------------------------------+------+-----
+---------+-------+
| Field | Type | Null | Key |
Default | Extra |
+------------------+---------------------------------+------+-----
+---------+-------+
| id_pinjam | int(5) | NO | | NULL
| |
| id_buku | int(5) | NO | | NULL
| |
| tgl_pengembalian | date | NO | | NULL
| |
| denda | double | NO | | NULL
| |
| status_buku | enum('Kembali','Belum Kembali') | YES | | NULL
| |
+------------------+---------------------------------+------+-----
+---------+-------+
5 rows in set (0.012 sec)

MariaDB [db_perpusweb]> desc katalog_buku;


+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| id_katalog | int(5) | NO | PRI | NULL | auto_increment |
| nama_katalog | varchar(45) | NO | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
2 rows in set (0.018 sec)

MariaDB [db_perpusweb]> desc peminjam;


+-------------+---------------------------------+------+-----+---------
+----------------+
| Field | Type | Null | Key | Default |
Extra |
+-------------+---------------------------------+------+-----+---------
+----------------+
| id_pinjam | int(5) | NO | PRI | NULL |
auto_increment |
| id_anggota | int(5) | NO | | NULL |
|
| tgl_pinjam | date | NO | | NULL |
|
| tgl_kembali | date | NO | | NULL |
|
| status | enum('Selesai','Belum Selesai') | YES | | NULL |
|
| Jml_buku | int(2) | NO | | NULL |
|
+-------------+---------------------------------+------+-----+---------
+----------------+
6 rows in set (0.013 sec)

MariaDB [db_perpusweb]> select*from buku;


+---------+------------+----------------------+------------------
+------------+----------------+
| id_buku | id_katalog | judul_buku | pengarang |
thn_terbit | penerbit |
+---------+------------+----------------------+------------------
+------------+----------------+
| 1 | 1 | Robotika Sederhana | Siswoyo Utomo | 2013-
01-01 | Wacana Ria |
| 2 | 2 | Mahir dengan PHP | Adri Kusuma | 2011-
02-02 | Pustaka Bangsa |
| 3 | 3 | Mahir Mewarnai | Akhmad Rahmat | 2014-
03-03 | CV.Indo Kreasi |
| 4 | 4 | Hukum Fisika | Kurnia sandi | 2013-
04-04 | Wacana Ria |
| 5 | 5 | Mahir Bahasa Inggris | Aliaddin | 2013-
05-05 | CV.Indo Kreasi |
| 6 | 6 | Public Speaking | Pambudi Prasetyo | 2015-
06-06 | Aldi Pustaka |
| 7 | 7 | Trik SQL | Ahdim makaren | 2014-
07-07 | Wacana Ria |
| 8 | 8 | Kemurnia agama | Pambudi Prasetyo | 2014-
08-08 | Aldi Pustaka |
| 9 | 9 | Mikrokontroler | Ahdim Makaren | 2012-
09-09 | Wacana Ria |
+---------+------------+----------------------+------------------
+------------+----------------+
9 rows in set (0.000 sec)

MariaDB [db_perpusweb]> select*from anggota;


Empty set (0.001 sec)

MariaDB [db_perpusweb]> insert into anggota


-> (nama,no_tlpn,alamat,email,password)
-> values
-> ('Irfan maulana','02136547854','BSD','[email protected]','111'),
-> ('Nur kumalasari','0896541344','Ciledug','[email protected]','222'),
-> ('Sanjaya
wijaya','0896542374','Cinone','[email protected]','333'),
-> ('Eva
Irfiansyah','0896542365','Tanggerang','[email protected]','444'),
-> ('Ifqoh
Permatasari','089654485','Cengkareng','[email protected]','555'),
-> ('Indah Riana','0896525825','Fatmawati','[email protected]','666'),
-> ('Tiwie Andrawati','0896525898','warung
jati','[email protected]','777'),
-> ('Mus dalifah','0896525455','jatiwaringin','[email protected]','888'),
-> ('Hisbu Utomo','058665312455','salemba','[email protected]','999'),
-> ('sahrul
gunawan','08665214658','Bekasi','[email protected]','010');
Query OK, 10 rows affected (0.004 sec)
Records: 10 Duplicates: 0 Warnings: 0

MariaDB [db_perpusweb]> select *from anggota;


+------------+-------------------+--------------+--------------
+-------------------+----------+
| id_anggota | nama | no_tlpn | alamat | email
| password |
+------------+-------------------+--------------+--------------
+-------------------+----------+
| 1 | Irfan maulana | 02136547854 | BSD |
[email protected] | 111 |
| 2 | Nur kumalasari | 0896541344 | Ciledug |
[email protected] | 222 |
| 3 | Sanjaya wijaya | 0896542374 | Cinone |
[email protected] | 333 |
| 4 | Eva Irfiansyah | 0896542365 | Tanggerang |
[email protected] | 444 |
| 5 | Ifqoh Permatasari | 089654485 | Cengkareng |
[email protected] | 555 |
| 6 | Indah Riana | 0896525825 | Fatmawati |
[email protected] | 666 |
| 7 | Tiwie Andrawati | 0896525898 | warung jati |
[email protected] | 777 |
| 8 | Mus dalifah | 0896525455 | jatiwaringin |
[email protected] | 888 |
| 9 | Hisbu Utomo | 058665312455 | salemba |
[email protected] | 999 |
| 10 | sahrul gunawan | 08665214658 | Bekasi |
[email protected] | 010 |
+------------+-------------------+--------------+--------------
+-------------------+----------+
10 rows in set (0.001 sec)

MariaDB [db_perpusweb]> select*from buku where penerbit ="wacana ria";


+---------+------------+--------------------+---------------+------------
+------------+
| id_buku | id_katalog | judul_buku | pengarang | thn_terbit
| penerbit |
+---------+------------+--------------------+---------------+------------
+------------+
| 1 | 1 | Robotika Sederhana | Siswoyo Utomo | 2013-01-01
| Wacana Ria |
| 4 | 4 | Hukum Fisika | Kurnia sandi | 2013-04-04
| Wacana Ria |
| 7 | 7 | Trik SQL | Ahdim makaren | 2014-07-07
| Wacana Ria |
| 9 | 9 | Mikrokontroler | Ahdim Makaren | 2012-09-09
| Wacana Ria |
+---------+------------+--------------------+---------------+------------
+------------+
4 rows in set (0.001 sec)

MariaDB [db_perpusweb]> select*from buku where pengarang="pambudi


prasetyo";
+---------+------------+-----------------+------------------+------------
+--------------+
| id_buku | id_katalog | judul_buku | pengarang | thn_terbit
| penerbit |
+---------+------------+-----------------+------------------+------------
+--------------+
| 6 | 6 | Public Speaking | Pambudi Prasetyo | 2015-06-06
| Aldi Pustaka |
| 8 | 8 | Kemurnia agama | Pambudi Prasetyo | 2014-08-08
| Aldi Pustaka |
+---------+------------+-----------------+------------------+------------
+--------------+
2 rows in set (0.000 sec)

MariaDB [db_perpusweb]> select pengarang,penerbit,judul_buku as


buku_tersedia from buku;
+------------------+----------------+----------------------+
| pengarang | penerbit | buku_tersedia |
+------------------+----------------+----------------------+
| Siswoyo Utomo | Wacana Ria | Robotika Sederhana |
| Adri Kusuma | Pustaka Bangsa | Mahir dengan PHP |
| Akhmad Rahmat | CV.Indo Kreasi | Mahir Mewarnai |
| Kurnia sandi | Wacana Ria | Hukum Fisika |
| Aliaddin | CV.Indo Kreasi | Mahir Bahasa Inggris |
| Pambudi Prasetyo | Aldi Pustaka | Public Speaking |
| Ahdim makaren | Wacana Ria | Trik SQL |
| Pambudi Prasetyo | Aldi Pustaka | Kemurnia agama |
| Ahdim Makaren | Wacana Ria | Mikrokontroler |
+------------------+----------------+----------------------+
9 rows in set (0.000 sec)

MariaDB [db_perpusweb]> select judul_buku,pengarang,thn_terbit from buku;


+----------------------+------------------+------------+
| judul_buku | pengarang | thn_terbit |
+----------------------+------------------+------------+
| Robotika Sederhana | Siswoyo Utomo | 2013-01-01 |
| Mahir dengan PHP | Adri Kusuma | 2011-02-02 |
| Mahir Mewarnai | Akhmad Rahmat | 2014-03-03 |
| Hukum Fisika | Kurnia sandi | 2013-04-04 |
| Mahir Bahasa Inggris | Aliaddin | 2013-05-05 |
| Public Speaking | Pambudi Prasetyo | 2015-06-06 |
| Trik SQL | Ahdim makaren | 2014-07-07 |
| Kemurnia agama | Pambudi Prasetyo | 2014-08-08 |
| Mikrokontroler | Ahdim Makaren | 2012-09-09 |
+----------------------+------------------+------------+
9 rows in set (0.001 sec)

MariaDB [db_perpusweb]> select *from anggota where left(nama,2)="mu";


+------------+-------------+------------+--------------+---------------
+----------+
| id_anggota | nama | no_tlpn | alamat | email |
password |
+------------+-------------+------------+--------------+---------------
+----------+
| 8 | Mus dalifah | 0896525455 | jatiwaringin | [email protected] |
888 |
+------------+-------------+------------+--------------+---------------
+----------+
1 row in set (0.001 sec)

MariaDB [db_perpusweb]> select nama,no_tlpn,alamat,email from anggota


where alamat not in('salemba');
+-------------------+-------------+--------------+-------------------+
| nama | no_tlpn | alamat | email |
+-------------------+-------------+--------------+-------------------+
| Irfan maulana | 02136547854 | BSD | [email protected] |
| Nur kumalasari | 0896541344 | Ciledug | [email protected] |
| Sanjaya wijaya | 0896542374 | Cinone | [email protected] |
| Eva Irfiansyah | 0896542365 | Tanggerang | [email protected] |
| Ifqoh Permatasari | 089654485 | Cengkareng | [email protected] |
| Indah Riana | 0896525825 | Fatmawati | [email protected] |
| Tiwie Andrawati | 0896525898 | warung jati | [email protected] |
| Mus dalifah | 0896525455 | jatiwaringin | [email protected] |
| sahrul gunawan | 08665214658 | Bekasi | [email protected] |
+-------------------+-------------+--------------+-------------------+
9 rows in set (0.002 sec)

MariaDB [db_perpusweb]> select*from anggota where right(no_tlpn,3)="825";


+------------+-------------+------------+-----------+-----------------
+----------+
| id_anggota | nama | no_tlpn | alamat | email |
password |
+------------+-------------+------------+-----------+-----------------
+----------+
| 6 | Indah Riana | 0896525825 | Fatmawati | [email protected] |
666 |
+------------+-------------+------------+-----------+-----------------
+----------+
1 row in set (0.001 sec)

MariaDB [db_perpusweb]> select nama,no_tlpn,alamat,email from anggota


where alamat not in('salemba');
+-------------------+-------------+--------------+-------------------+
| nama | no_tlpn | alamat | email |
+-------------------+-------------+--------------+-------------------+
| Irfan maulana | 02136547854 | BSD | [email protected] |
| Nur kumalasari | 0896541344 | Ciledug | [email protected] |
| Sanjaya wijaya | 0896542374 | Cinone | [email protected] |
| Eva Irfiansyah | 0896542365 | Tanggerang | [email protected] |
| Ifqoh Permatasari | 089654485 | Cengkareng | [email protected] |
| Indah Riana | 0896525825 | Fatmawati | [email protected] |
| Tiwie Andrawati | 0896525898 | warung jati | [email protected] |
| Mus dalifah | 0896525455 | jatiwaringin | [email protected] |
| sahrul gunawan | 08665214658 | Bekasi | [email protected] |
+-------------------+-------------+--------------+-------------------+
9 rows in set (0.001 sec)

MariaDB [db_perpusweb]>

You might also like