0% found this document useful (0 votes)
38 views9 pages

Uas Basis Data Essay No 1: Nama: Delia Akmalia NIM: 20220050164 Kelas: SI22F

The document details the creation of customer and orders database tables in MariaDB. It creates customer and customer2 tables to store customer data, and an orders table to store order information. It then inserts sample data and performs some queries on the tables, such as a union query to combine data from the customer and customer2 tables.

Uploaded by

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

Uas Basis Data Essay No 1: Nama: Delia Akmalia NIM: 20220050164 Kelas: SI22F

The document details the creation of customer and orders database tables in MariaDB. It creates customer and customer2 tables to store customer data, and an orders table to store order information. It then inserts sample data and performs some queries on the tables, such as a union query to combine data from the customer and customer2 tables.

Uploaded by

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

UAS BASIS DATA

ESSAY NO 1

NAMA : Delia Akmalia


NIM : 20220050164
KELAS : SI22F

C:\Users\Asus>cd..
C:\Users>cd..
C:\>cd xampp/mysql/bin
C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
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)]> create database penjualan;
Query OK, 1 row affected (0.011 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| akademik |
| barang1 |
| db_penjualan |
| gaji |
| gaji1 |
| information_schema |
| latihan |
| mysql |
| penjualan |
| performance_schema |
| phpmyadmin |
| test |
| ujianf |
+--------------------+
13 rows in set (0.080 sec)

MariaDB [(none)]> use penjualan;


Database changed
MariaDB [penjualan]> create table customer;
ERROR 1113 (42000): A table must have at least 1 column
MariaDB [penjualan]> create table customer (
-> customer_id varchar (15) Not Null Primary key,
-> customer_name varchar (20) Not Null,
-> customer_addres varchar (20) Not Null);
Query OK, 0 rows affected (0.039 sec)

MariaDB [penjualan]> desc customer;


+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| customer_id | varchar(15) | NO | PRI | NULL | |
| customer_name | varchar(20) | NO | | NULL | |
| customer_addres | varchar(20) | NO | | NULL | |
+-----------------+-------------+------+-----+---------+-------+
3 rows in set (0.037 sec)

MariaDB [penjualan]> insert into customer (customer_id,customer_name,customer_addres) values


-> ('CS001', 'Aan', 'pasuruan'),
-> ('CS002', 'Hanif','Banyuwangi'),
-> ('CS003', 'Mirza','Malang'),
-> ('CS004', 'Tanti','Tegal'),
-> ('CS005', 'Budie','Kediri');
Query OK, 5 rows affected (0.119 sec)
Records: 5 Duplicates: 0 Warnings: 0

MariaDB [penjualan]> select * from customer;


+-------------+---------------+-----------------+
| customer_id | customer_name | customer_addres |
+-------------+---------------+-----------------+
| CS001 | Aan | pasuruan |
| CS002 | Hanif | Banyuwangi |
| CS003 | Mirza | Malang |
| CS004 | Tanti | Tegal |
| CS005 | Budie | Kediri |
+-------------+---------------+-----------------+
5 rows in set (0.001 sec)

MariaDB [penjualan]> create table orders (


-> order_id varchar (10) Not Null Primary Key,
-> order_date int (20) Not Null,
-> cs_id varchar (10) Not Null,
-> qty int (10) Not Null,
-> amount int (10) Not Null);
Query OK, 0 rows affected (0.034 sec)

MariaDB [penjualan]> insert into orders(order_id,order_date,cs_id,qty,amount) values


-> ('CS001','10-12-2016','CS001','1','40000'),
-> ('CS002','11-01-2017','CS002','2','50000'),
-> ('CS003','12-01-2017','CS003','3','35000');
Query OK, 3 rows affected, 3 warnings (0.014 sec)
Records: 3 Duplicates: 0 Warnings: 3

MariaDB [penjualan]> select * from orders;


+----------+------------+-------+-----+--------+
| order_id | order_date | cs_id | qty | amount |
+----------+------------+-------+-----+--------+
| CS001 | 10 | CS001 | 1 | 40000 |
| CS002 | 11 | CS002 | 2 | 50000 |
| CS003 | 12 | CS003 | 3 | 35000 |
+----------+------------+-------+-----+--------+
3 rows in set (0.001 sec)

MariaDB [penjualan]> alter table konsumen modify order_date date;


ERROR 1146 (42S02): Table 'penjualan.konsumen' doesn't exist
MariaDB [penjualan]> create table orders(
-> order_id varchar (10) Not Null primary key,
-> order_tgl date,
-> cs_id varchar (10) Not Null,
-> qty int (10) Not Null,
-> Amount int (10) Not Null);
ERROR 1050 (42S01): Table 'orders' already exists
MariaDB [penjualan]> drop table orders;
Query OK, 0 rows affected (0.048 sec)

MariaDB [penjualan]> create table orders(


-> order_id varchar (10) Not Null primary key,
-> order_tgl date,
-> cs_id varchar (10) Not Null,
-> qty int (10) Not Null,
-> Amount int (10) Not Null);
Query OK, 0 rows affected (0.026 sec)

MariaDB [penjualan]> insert into orders(order_id,order_tgl,cs_id,qty,amount) values


-> ('CS001','10-12-2016','CS001','1','40000'),
-> ('CS002','11-01-2017','CS002','2','50000'),
-> ('CS003','12-01-2017','CS003','3','35000');
Query OK, 3 rows affected, 3 warnings (0.016 sec)
Records: 3 Duplicates: 0 Warnings: 3

MariaDB [penjualan]> select * from orders;


+----------+------------+-------+-----+--------+
| order_id | order_tgl | cs_id | qty | Amount |
+----------+------------+-------+-----+--------+
| CS001 | 0000-00-00 | CS001 | 1 | 40000 |
| CS002 | 0000-00-00 | CS002 | 2 | 50000 |
| CS003 | 0000-00-00 | CS003 | 3 | 35000 |
+----------+------------+-------+-----+--------+
3 rows in set (0.001 sec)

MariaDB [penjualan]> drop table orders;


Query OK, 0 rows affected (0.039 sec)

MariaDB [penjualan]> create table orders(


-> order_id varchar (10) Not Null primary key,
-> order_tgl date,
-> cs_id varchar (10) Not Null,
-> qty int (10) Not Null,
-> Amount int (10) Not Null);
Query OK, 0 rows affected (0.037 sec)

MariaDB [penjualan]> insert into orders(order_id,order_tgl,cs_id,qty,amount) values


-> ('CS001','2016-12-10','CS001','1','40000'),
-> ('CS002','2017-01-11','CS002','2','50000'),
-> ('CS003','2017-01-12','CS003','3','35000');
Query OK, 3 rows affected (0.015 sec)
Records: 3 Duplicates: 0 Warnings: 0
MariaDB [penjualan]> select * from orders;
+----------+------------+-------+-----+--------+
| order_id | order_tgl | cs_id | qty | Amount |
+----------+------------+-------+-----+--------+
| CS001 | 2016-12-10 | CS001 | 1 | 40000 |
| CS002 | 2017-01-11 | CS002 | 2 | 50000 |
| CS003 | 2017-01-12 | CS003 | 3 | 35000 |
+----------+------------+-------+-----+--------+
3 rows in set (0.001 sec)

MariaDB [penjualan]> select costumer.customer_id, orders.order_tgl, orders.amount from costumer


inner join orders on costumer.customer_id=orders.cs_id;
ERROR 1146 (42S02): Table 'penjualan.costumer' doesn't exist
MariaDB [penjualan]> select costumer.customer_id, orders.order_tgl, orders.amount from custumer
inner join orders on costumer.customer_id=orders.cs_id;
ERROR 1146 (42S02): Table 'penjualan.custumer' doesn't exist
MariaDB [penjualan]> select customer.customer_id, orders.order_tgl, orders.amount from customer
inner join orders on customer.customer_id=orders.cs_id;
+-------------+------------+--------+
| customer_id | order_tgl | amount |
+-------------+------------+--------+
| CS001 | 2016-12-10 | 40000 |
| CS002 | 2017-01-11 | 50000 |
| CS003 | 2017-01-12 | 35000 |
+-------------+------------+--------+
3 rows in set (0.001 sec)

MariaDB [penjualan]> create table costumer2 (


-> customer_id varchar (15) not null primary key,
-> customer_name varchar (20) not null,
-> costumer_addres varchar (20) not null);
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 ' (20) not null)' at line 4
MariaDB [penjualan]> create table costumer2 (
-> customer_id varchar (15) not null primary key,
-> customer_name varchar (20) not null,
-> customer_addres varchar (20) not null);
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 ' (20) not null)' at line 4
MariaDB [penjualan]> create table custumer2 (
-> customer_id varchar (15) not null primary key,
-> customer_name varchar (10) not null,
-> customer_addres varchar (20) not null);
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 ' (20) not null)' at line 4
MariaDB [penjualan]> create table customer2(
-> customer_id varchar (10) Not Null primary key,
-> customer_name varchar (10) Not Null,
-> Customer_addres varchar (10) Not Null);
Query OK, 0 rows affected (0.037 sec)

MariaDB [penjualan]> insert into customer2(customer_id,customer_name,customer_addres) values


-> ('CS006','Nana','Bogor'),
-> ('CS007','Kiki','Sukabumi'),
-> ('CS008','Gigi','Jakarta'),
-> ('CS009','Hihi','Depok'),
-> ('CS010','Nini','Bekasi');
Query OK, 5 rows affected (0.014 sec)
Records: 5 Duplicates: 0 Warnings: 0

MariaDB [penjualan]> select * from customer union select * from customer2;


+-------------+---------------+-----------------+
| customer_id | customer_name | customer_addres |
+-------------+---------------+-----------------+
| CS001 | Aan | pasuruan |
| CS002 | Hanif | Banyuwangi |
| CS003 | Mirza | Malang |
| CS004 | Tanti | Tegal |
| CS005 | Budie | Kediri |
| CS006 | Nana | Bogor |
| CS007 | Kiki | Sukabumi |
| CS008 | Gigi | Jakarta |
| CS009 | Hihi | Depok |
| CS010 | Nini | Bekasi |
+-------------+---------------+-----------------+
10 rows in set (0.001 sec)

Hasil:

You might also like