The document describes creating databases and tables, inserting data, and performing various types of joins in MariaDB. It creates a Kantor_wdy database with Karyawan and Departemen tables, inserts employee and department data, and runs queries using inner, left outer, right outer, and cross joins to relate the tables and return selected columns of data.
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 ratings0% found this document useful (0 votes)
39 views
Sistem Basis Data
The document describes creating databases and tables, inserting data, and performing various types of joins in MariaDB. It creates a Kantor_wdy database with Karyawan and Departemen tables, inserts employee and department data, and runs queries using inner, left outer, right outer, and cross joins to relate the tables and return selected columns of data.
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/ 6
TUGAS
PRAKTIKUM SISTEM BASIS DATA
NAMA : Syahruni Widya Ningsi
KELAS : H (TEKNIK INFORAMATIKA)
NIM : 192272
SEKOLAH TINGGI ILMU MANAGEMENT DAN
KOMPUTER (STMIK) DIPANEGARA MAKASSAR 2020 Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\galery>cd.. C:\Users>cd.. C:\>cd xampp C:\xampp>cd mysql C:\xampp\mysql>cd 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.31-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)]> CREATE DATABASE Kantor_wdy -> ; Query OK, 1 row affected (0.07 sec) MariaDB [(none)]> USE Kantor_wdy Database changed MariaDB [Kantor_wdy]> CREATE TABLE Karyawan ( -> nama VARCHAR(30) NOT NULL, -> id_dep INT(5) NOT NULL -> ) ENGINE=MyISAM; Query OK, 0 rows affected (0.07 sec)
-> FROM KARYAWAN -> INNER JOIN DEPARTEMEN -> ON KARYAWAN.id_dep=DEPARTEMEN.id_dep; +-------+------------+ | nama | nama_dep | +-------+------------+ | Agus | Penelitian | | Citra | SDM | +-------+------------+ 2 rows in set (0.00 sec)
MariaDB [Kantor_wdy]> SELECT k.nama, d.nama_dep
-> FROM KARYAWAN -> INNER JOIN departemen d -> ON k.id_dep=d.id_dep; ERROR 1054 (42S22): Unknown column 'k.nama' in 'field list' MariaDB [Kantor_wdy]> SELECT k.nama, d.nama_dep -> FROM KARYAWAN k -> INNER JOIN departemen d -> ON k.id_dep=d.id_dep; +-------+------------+ | nama | nama_dep | +-------+------------+ | Agus | Penelitian | | Citra | SDM | +-------+------------+ 2 rows in set (0.00 sec)
MariaDB [Kantor_wdy]> SELECT *
-> FROM KARYAWAN k -> left outer departemen d -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'dep artemen d' at line 3 MariaDB [Kantor_wdy]> SELECT * -> FROM KARYAWAN k -> left outer join departemen d -> ON k.id_dep=d.id_dep; +-------+--------+--------+------------+ | nama | id_dep | id_dep | nama_dep | +-------+--------+--------+------------+ | Agus | 10 | 10 | Penelitian | | Budi | 16 | NULL | NULL | | Citra | 12 | 12 | SDM | | Dani | 17 | NULL | NULL | +-------+--------+--------+------------+ 4 rows in set (0.00 sec)
MariaDB [Kantor_wdy]> SELECT *
-> FROM KARYAWAN k -> left outer join departemen d -> ON k.id_dep=d.id_dep -> WHERE d.id_dep IS NULL; +------+--------+--------+----------+ | nama | id_dep | id_dep | nama_dep | +------+--------+--------+----------+ | Budi | 16 | NULL | NULL | | Dani | 17 | NULL | NULL | +------+--------+--------+----------+ 2 rows in set (0.00 sec)
MariaDB [Kantor_wdy]> SELECT *
-> FROM KARYAWAN k -> RIGHT OUTER JOIN departemen d -> ON k.id_dep=d.id_dep; +-------+--------+--------+------------+ | nama | id_dep | id_dep | nama_dep | +-------+--------+--------+------------+ | Agus | 10 | 10 | Penelitian | | Citra | 12 | 12 | SDM | | NULL | NULL | 11 | Pemasaran | | NULL | NULL | 13 | Keuangan | +-------+--------+--------+------------+ 4 rows in set (0.00 sec)
MariaDB [Kantor_wdy]> SELECT *
-> FROM KARYAWAN k -> left outer join departemen d -> ON k.id_dep=d.id_dep -> UNION -> SELECT * -> FROM KARYAWAN k -> right outer join departemen d -> ON k.id_dep=d.id_dep; +-------+--------+--------+------------+ | nama | id_dep | id_dep | nama_dep | +-------+--------+--------+------------+ | Agus | 10 | 10 | Penelitian | | Budi | 16 | NULL | NULL | | Citra | 12 | 12 | SDM | | Dani | 17 | NULL | NULL | | NULL | NULL | 11 | Pemasaran | | NULL | NULL | 13 | Keuangan | +-------+--------+--------+------------+ 6 rows in set (0.01 sec)