0% found this document useful (0 votes)
9 views4 pages

Modul 4 MBD

The document shows SQL commands used to create and populate databases, tables, and records in MariaDB. Various operations are demonstrated like inserting, selecting, updating, and deleting records in different tables to store employee data including personal details and job details.

Uploaded by

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

Modul 4 MBD

The document shows SQL commands used to create and populate databases, tables, and records in MariaDB. Various operations are demonstrated like inserting, selecting, updating, and deleting records in different tables to store employee data including personal details and job details.

Uploaded by

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

Microsoft Windows [Version 10.0.17134.

648]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Asus>cd\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 2
Server version: 10.1.10-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2015, 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 |
+--------------------+
| bress |
| information_schema |
| mysql |
| pegawai_018 |
| performance_schema |
| phpmyadmin |
| quis018 |
| test |
| tugas_asistensi018 |
+--------------------+
9 rows in set (0.18 sec)

MariaDB [(none)]> use pegawai_018;


Database changed
MariaDB [pegawai_018]> show tables;
+-----------------------+
| Tables_in_pegawai_018 |
+-----------------------+
| bagian |
| pekerjaan |
| pribadi |
+-----------------------+
3 rows in set (0.04 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('1234','M SLamed H','1998/05/30','P','Ds Dasok','Pamekasan');
Query OK, 1 row affected (0.16 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,alamat) values


('1235','Ayu','Ds Nawangan');
Query OK, 1 row affected (0.12 sec)

MariaDB [pegawai_018]> select * from pribadi;


+------+------------+------------+---------+-------------+-----------+
| NIP | Nama | Tgl_lahir | kelamin | Alamat | KOTA |
+------+------------+------------+---------+-------------+-----------+
| 1234 | M SLamed H | 1998-05-30 | P | Ds Dasok | Pamekasan |
| 1235 | Ayu | NULL | P | Ds Nawangan | NULL |
+------+------------+------------+---------+-------------+-----------+
2 rows in set (0.00 sec)
MariaDB [pegawai_018]> update pribadi set
Tgl_lahir='1998/03/30',kelamin='W',kota='Tuban' where nip='1235';
Query OK, 1 row affected (0.11 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [pegawai_018]> select * from pribadi;


+------+------------+------------+---------+-------------+-----------+
| NIP | Nama | Tgl_lahir | kelamin | Alamat | KOTA |
+------+------------+------------+---------+-------------+-----------+
| 1234 | M SLamed H | 1998-05-30 | P | Ds Dasok | Pamekasan |
| 1235 | Ayu | 1998-03-30 | W | Ds Nawangan | Tuban |
+------+------------+------------+---------+-------------+-----------+
2 rows in set (0.00 sec)

MariaDB [pegawai_018]> delete from pribadi where nip='1234';


Query OK, 1 row affected (0.09 sec)

MariaDB [pegawai_018]> select * from pribadi;


+------+------+------------+---------+-------------+-------+
| NIP | Nama | Tgl_lahir | kelamin | Alamat | KOTA |
+------+------+------------+---------+-------------+-------+
| 1235 | Ayu | 1998-03-30 | W | Ds Nawangan | Tuban |
+------+------+------------+---------+-------------+-------+
1 row in set (0.00 sec)

MariaDB [pegawai_018]> insert into bagian (kode_bag,nama_bag) values('1','EDP');


Query OK, 1 row affected (0.11 sec)

MariaDB [pegawai_018]> insert into bagian (kode_bag,nama_bag)


values('2','Pemasaran'),('3','Produksi'),('4','SDM'),('5','Akunting');
Query OK, 4 rows affected (0.12 sec)
Records: 4 Duplicates: 0 Warnings: 0

MariaDB [pegawai_018]> select * from bagian;


+----------+-----------+
| Kode_bag | Nama_bag |
+----------+-----------+
| 1 | EDP |
| 2 | Pemasaran |
| 3 | Produksi |
| 4 | SDM |
| 5 | Akunting |
+----------+-----------+
5 rows in set (0.00 sec)

MariaDB [pegawai_018]> alter table pribadi add column bisa_bhs_asing enum('T','F')


default 'F';
Query OK, 0 rows affected (0.65 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [pegawai_018]> desc pribadi;


+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| NIP | char(6) | NO | PRI | NULL | |
| Nama | varchar(35) | NO | | NULL | |
| Tgl_lahir | date | YES | | NULL | |
| kelamin | enum('P','W') | YES | | P | |
| Alamat | varchar(35) | YES | | NULL | |
| KOTA | varchar(20) | YES | | NULL | |
| bisa_bhs_asing | enum('T','F') | YES | | F | |
+----------------+---------------+------+-----+---------+-------+
7 rows in set (0.11 sec)

MariaDB [pegawai_018]> alter table pribadi drop bisa_bhs_asing;


Query OK, 0 rows affected (0.49 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [pegawai_018]> desc pribadi;


+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| NIP | char(6) | NO | PRI | NULL | |
| Nama | varchar(35) | NO | | NULL | |
| Tgl_lahir | date | YES | | NULL | |
| kelamin | enum('P','W') | YES | | P | |
| Alamat | varchar(35) | YES | | NULL | |
| KOTA | varchar(20) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
6 rows in set (0.03 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('311301','dono','1994/04/21','P','jl salak','bekasi');
Query OK, 1 row affected (0.06 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('311302','dini','1995/10/11','W','jl durian','jakarta');
Query OK, 1 row affected (0.06 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('311303','deni','1996/01/03','P','jl semangka','surabaya');
Query OK, 1 row affected (0.07 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('311304','sari','1997/01/02','W','jl jeruk','bangkalan');
Query OK, 1 row affected (0.10 sec)

MariaDB [pegawai_018]> insert into pribadi (nip,nama,tgl_lahir,kelamin,alamat,kota)


values ('311305','indro','1995/12/30','P','jl pepaya','gresik');
Query OK, 1 row affected (0.06 sec)

MariaDB [pegawai_018]> select * from pribadi;


+--------+-------+------------+---------+-------------+-----------+
| NIP | Nama | Tgl_lahir | kelamin | Alamat | KOTA |
+--------+-------+------------+---------+-------------+-----------+
| 1235 | Ayu | 1998-03-30 | W | Ds Nawangan | Tuban |
| 311301 | dono | 1994-04-21 | P | jl salak | bekasi |
| 311302 | dini | 1995-10-11 | W | jl durian | jakarta |
| 311303 | deni | 1996-01-03 | P | jl semangka | surabaya |
| 311304 | sari | 1997-01-02 | W | jl jeruk | bangkalan |
| 311305 | indro | 1995-12-30 | P | jl pepaya | gresik |
+--------+-------+------------+---------+-------------+-----------+
6 rows in set (0.00 sec)

MariaDB [pegawai_018]> insert into pekerjaan (nip,tgl_masuk,kode_bag,gaji)


values('311301','2014/02/03','1','1000000');
Query OK, 1 row affected (0.12 sec)
MariaDB [pegawai_018]> insert into pekerjaan (nip,tgl_masuk,kode_bag,gaji)
values('311302','2015/03/04','2','3000000');
Query OK, 1 row affected (0.08 sec)

MariaDB [pegawai_018]> insert into pekerjaan (nip,tgl_masuk,kode_bag,gaji)


values('311303','2015/07/20','3','2000000');
Query OK, 1 row affected (0.06 sec)

MariaDB [pegawai_018]> insert into pekerjaan (nip,tgl_masuk,kode_bag,gaji)


values('311304','2016/09/05','4','1500000');
Query OK, 1 row affected (0.07 sec)

MariaDB [pegawai_018]> insert into pekerjaan (nip,tgl_masuk,kode_bag,gaji)


values('311305','2017/05/15','5','2500000');
Query OK, 1 row affected (0.07 sec)

MariaDB [pegawai_018]> select * from pekerjaan;


+--------+------------+----------+---------+
| Nip | Tgl_masuk | Kode_bag | Gaji |
+--------+------------+----------+---------+
| 311301 | 2014-02-03 | 1 | 1000000 |
| 311302 | 2015-03-04 | 2 | 3000000 |
| 311303 | 2015-07-20 | 3 | 2000000 |
| 311304 | 2016-09-05 | 4 | 1500000 |
| 311305 | 2017-05-15 | 5 | 2500000 |
+--------+------------+----------+---------+
5 rows in set (0.00 sec)

MariaDB [pegawai_018]>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy