You are on page 1of 11

Nama : Elmi Tiodata

Matkul : Manajemen Basis Data


NPM : 210403010022
Dosen : Wahyudi Harianto, S.Kom., M.Si.

1. CREATE
 CREATE DATABASE produk
CREATE TABLE IF NOT EXISTS `tblproduk` (
`NIPR` varchar(15) NOT NULL,
`Nama` varchar(30) NOT NULL,
`Tipe` varchar(30) NOT NULL,
`Garansi` varchar(30) NOT NULL,
`Core!` varchar(30) NOT NULL,
`Jenis` text NOT NULL,
PRIMARY KEY (`NIPR`))
 CREATE TABLE IF NOT EXISTS `tblsupp` (
`Id` int(5) NOT NULL AUTO_INCREMENT,
`Suppname` varchar(15) NOT NULL,
`Telpon` varchar(15) NOT NULL,
`NIPR` varchar(15) NOT NULL,
PRIMARY KEY (`Id`))

2. INSERT
 INSERT INTO `tblproduk` (`NIPR`, `Nama`, `Jenis`,’Tipe’,’Garansi’,’Core!’) VALUES
o ('101', 'Asus Pro', 'Laptop'),
o ('102', 'Lenovo', 'Laptop'),
o ('103', 'Acer', 'Laptop'),
o ('104', 'Dell', 'Laptop'),
o ('201', 'Samsung', 'Handphone'),
o ('202', 'Oppo', 'Handphone'),
o ('203', 'Vivo', 'Handphone'),
o ('204', 'Xiaomi', 'Handphone'),
o ('301', 'Sony', 'Camera'),
o ('302', 'Kodak', 'Camera'),
o ('303', 'Casio', 'Camera'),
o ('401', 'HP', 'Printer'),
o ('402', 'Epson', 'Printer');
 INSERT INTO `tblsupp` (`Id`, `suppname`, `NIPR`,’Telpon’) VALUES

o ('106', 'PT.Trijaya', '085389006855'),


o ('102', 'PT.Trijaya', '085789008932'),
o ('103', 'ELSComp',’083456278900),
o ('104', 'ELSComp',’085789006811),
o ('201', 'Metrodigital', '0856789023'),
o ('202', 'Metrodigital',’5678902003312),
o ('203', ' XtraNet',’08578738900),
o ('204',’XtraNet',’08563426234),
o ('301', 'PT Global Tama',’ 085789008932),
o ('302', 'PT.Global Tama',’ 083456278900’),
o ('303', 'PT.Global Tama',’ 085789006811),
o ('401', 'CV SAT Comp’,’ 085789008932’),
o ('402', 'CV SAT Comp’,’ 085789006811’);

3. UPDATE
 SELECT * FROM tblproduk;
UPDATE tblproduk SET Nama = 'Samsung'
WHERE Nama ='Asus Pro'
 Select * FROM tblsupp;
SELECT * FROM tblsupp;
UPDATE tblsupp SET NIPR = '106'
WHERE NIPR = '101
4. DELETE
 DELETE FROM `tblsupp` WHERE NIPR='402'
 DELETE FROM `tblproduk` WHERE Nama='Epson'

Setting environment for using XAMPP for Windows.


SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# myql -u root -p
'myql' is not recognized as an internal or external command,
operable program or batch file.

SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
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 mahasiswa;
Query OK, 1 row affected (0.013 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| apotik |
| cias |
| db_apksurat |
| db_apksuratelmi |
| information_schema |
| jualproduk |
| kampus |
| mahasiswa |
| mahasiwa |
| mysql |
| performance_schema |
| perpustakaan |
| perpustakaan1 |
| perpustakaan2 |
| perpustakaan3 |
| perpustakaan4 |
| perpustakaan5 |
| pesan_brng |
| phpmyadmin |
| produk |
| test |
+--------------------+
21 rows in set (0.001 sec)

MariaDB [(none)]> use mahasiswa;


Database changed
MariaDB [mahasiswa]> show tables;
Empty set (0.002 sec)

MariaDB [mahasiswa]> create table tbmahasiswa(


-> id int primary key,
-> nama varchar(12) not null,
-> nama varchar (30) not null,
-> alamat varchar (35))
-> ;
ERROR 1060 (42S21): Duplicate column name 'nama'
MariaDB [mahasiswa]> \clear
->
-> ;
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
'lear' at line 1
MariaDB [mahasiswa]> show database;
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
'database' at line 1
MariaDB [mahasiswa]> clear;
MariaDB [mahasiswa]> show tables;
Empty set (0.002 sec)

MariaDB [mahasiswa]> create table tbmahasiswa(


-> id int primary key,
-> nim varchar(12) not null,
-> nama varchar(30) not null,
-> alamat varchar(35));
Query OK, 0 rows affected (0.059 sec)

MariaDB [mahasiswa]> show tables;


+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nama_lengkap, nim, hobi)


-> values ('','Elmi','2201', 'Volly');
ERROR 1054 (42S22): Unknown column 'nama_lengkap' in 'field list'
MariaDB [mahasiswa]> show tables;
+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)


-> values(','Elmi','
->
->
-> show tables;
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
'Elmi','

show tables' at line 2


MariaDB [mahasiswa]> show tables;
+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)


-> velues ('02', '0022', 'ElMI', 'sigura-gura');
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
'velues ('02', '0022', 'ElMI', 'sigura-gura')' at line 2
MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> velues ('02', '0022', 'ElMI', 'sigura-gura');
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
'velues ('02', '0022', 'ElMI', 'sigura-gura')' at line 2
MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> values ('02', '0022', 'ElMI', 'sigura-gura');
Query OK, 1 row affected (0.042 sec)

MariaDB [mahasiswa]> MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim,


nama, alamat)
-> -> values ('02', '0022', 'ElMI', 'sigura-gura');
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
'MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> va...' at line 1
MariaDB [mahasiswa]> Query OK, 1 row affected (0.042 sec)
-> velues ('02', '0022', 'TIODATA', kesatrian');
'> MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
'> -> values ('02', '0022', 'ElMI', 'sigura-gura');
'> -> values ('02', '0022', 'ElMI', 'sigura-gura');
'> delete from tbmahasiswa where id='02';
'> velues ('02', '0022', 'ElMI', 'sigura-gura');
'> insert into tbmahasiswa(id, nim, nama, alamat);
'> exit()
'>
'>
'>
'> Bye

SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
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 |
+--------------------+
| apotik |
| cias |
| db_apksurat |
| db_apksuratelmi |
| information_schema |
| jualproduk |
| kampus |
| mahasiswa |
| mahasiwa |
| mysql |
| performance_schema |
| perpustakaan |
| perpustakaan1 |
| perpustakaan2 |
| perpustakaan3 |
| perpustakaan4 |
| perpustakaan5 |
| pesan_brng |
| phpmyadmin |
| produk |
| test |
+--------------------+
21 rows in set (0.002 sec)

MariaDB [(none)]> use mahasiswa;


Database changed
MariaDB [mahasiswa]> select * from tbmahasiswa;
+----+------+------+-------------+
| id | nim | nama | alamat |
+----+------+------+-------------+
| 2 | 0022 | ElMI | sigura-gura |
+----+------+------+-------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> delete from tbmahasiswa where id='2';


Query OK, 1 row affected (0.041 sec)

MariaDB [mahasiswa]>
Setting environment for using XAMPP for Windows.
SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# myql -u root -p
'myql' is not recognized as an internal or external command,
operable program or batch file.

SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
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 mahasiswa;


Query OK, 1 row affected (0.013 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| apotik |
| cias |
| db_apksurat |
| db_apksuratelmi |
| information_schema |
| jualproduk |
| kampus |
| mahasiswa |
| mahasiwa |
| mysql |
| performance_schema |
| perpustakaan |
| perpustakaan1 |
| perpustakaan2 |
| perpustakaan3 |
| perpustakaan4 |
| perpustakaan5 |
| pesan_brng |
| phpmyadmin |
| produk |
| test |
+--------------------+
21 rows in set (0.001 sec)
MariaDB [(none)]> use mahasiswa;
Database changed
MariaDB [mahasiswa]> show tables;
Empty set (0.002 sec)

MariaDB [mahasiswa]> create table tbmahasiswa(


-> id int primary key,
-> nama varchar(12) not null,
-> nama varchar (30) not null,
-> alamat varchar (35))
-> ;
ERROR 1060 (42S21): Duplicate column name 'nama'
MariaDB [mahasiswa]> \clear
->
-> ;
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
'lear' at line 1
MariaDB [mahasiswa]> show database;
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
'database' at line 1
MariaDB [mahasiswa]> clear;
MariaDB [mahasiswa]> show tables;
Empty set (0.002 sec)

MariaDB [mahasiswa]> create table tbmahasiswa(


-> id int primary key,
-> nim varchar(12) not null,
-> nama varchar(30) not null,
-> alamat varchar(35));
Query OK, 0 rows affected (0.059 sec)

MariaDB [mahasiswa]> show tables;


+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nama_lengkap, nim, hobi)


-> values ('','Elmi','2201', 'Volly');
ERROR 1054 (42S22): Unknown column 'nama_lengkap' in 'field list'
MariaDB [mahasiswa]> show tables;
+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)


-> values(','Elmi','
->
->
-> show tables;
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
'Elmi','

show tables' at line 2


MariaDB [mahasiswa]> show tables;
+---------------------+
| Tables_in_mahasiswa |
+---------------------+
| tbmahasiswa |
+---------------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)


-> velues ('02', '0022', 'ElMI', 'sigura-gura');
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
'velues ('02', '0022', 'ElMI', 'sigura-gura')' at line 2
MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> velues ('02', '0022', 'ElMI', 'sigura-gura');
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
'velues ('02', '0022', 'ElMI', 'sigura-gura')' at line 2
MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> values ('02', '0022', 'ElMI', 'sigura-gura');
Query OK, 1 row affected (0.042 sec)

MariaDB [mahasiswa]> MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim,


nama, alamat)
-> -> values ('02', '0022', 'ElMI', 'sigura-gura');
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
'MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
-> va...' at line 1
MariaDB [mahasiswa]> Query OK, 1 row affected (0.042 sec)
-> velues ('02', '0022', 'TIODATA', kesatrian');
'> MariaDB [mahasiswa]> insert into tbmahasiswa(id, nim, nama, alamat)
'> -> values ('02', '0022', 'ElMI', 'sigura-gura');
'> -> values ('02', '0022', 'ElMI', 'sigura-gura');
'> delete from tbmahasiswa where id='02';
'> velues ('02', '0022', 'ElMI', 'sigura-gura');
'> insert into tbmahasiswa(id, nim, nama, alamat);
'> exit()
'>
'>
'>
'> Bye

SusterPasionis@LAPTOP-BAJUJ3UJ c:\xampp 23
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
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 |
+--------------------+
| apotik |
| cias |
| db_apksurat |
| db_apksuratelmi |
| information_schema |
| jualproduk |
| kampus |
| mahasiswa |
| mahasiwa |
| mysql |
| performance_schema |
| perpustakaan |
| perpustakaan1 |
| perpustakaan2 |
| perpustakaan3 |
| perpustakaan4 |
| perpustakaan5 |
| pesan_brng |
| phpmyadmin |
| produk |
| test |
+--------------------+
21 rows in set (0.002 sec)

MariaDB [(none)]> use mahasiswa;


Database changed
MariaDB [mahasiswa]> select * from tbmahasiswa;
+----+------+------+-------------+
| id | nim | nama | alamat |
+----+------+------+-------------+
| 2 | 0022 | ElMI | sigura-gura |
+----+------+------+-------------+
1 row in set (0.001 sec)

MariaDB [mahasiswa]> delete from tbmahasiswa where id='2';


Query OK, 1 row affected (0.041 sec)

MariaDB [mahasiswa]>

You might also like