Sei sulla pagina 1di 7

Microsoft Windows [Version 10.0.18362.

207]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\user>
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 8
Server version: 10.4.10-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 kuliah;


Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| kuliah |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
6 rows in set (0.002 sec)

MariaDB [(none)]> drop 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 '' at
line 1
MariaDB [(none)]> create database kuliah;
ERROR 1007 (HY000): Can't create database 'kuliah'; database exists
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kuliah |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
6 rows in set (0.001 sec)

MariaDB [(none)]> create table nama(mahasiswa);


ERROR 1046 (3D000): No database selected
MariaDB [(none)]> create table mahasiswa(
->
-> ;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> use kuliah;
Database changed
MariaDB [kuliah]> create table nama(
-> nim varchar(10),
-> nama varchar(100)
-> ;
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 '' at
line 3
MariaDB [kuliah]>
MariaDB [kuliah]> create tabke nama(
-> nim varchar(10),
-> nama varchar(100),
-> jk char(1),
-> temp_lahir varchar(100),
-> tgl_lahir date,
-> primary key (nim));
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 'tabke
nama(
nim varchar(10),
nama varchar(100),
jk char(1),
temp_lahir varchar(1' at line 1
MariaDB [kuliah]> desc nama;
ERROR 1146 (42S02): Table 'kuliah.nama' doesn't exist
MariaDB [kuliah]> create tabke nama(
-> -> nim varchar(10),
-> -> nama varchar(100),
-> -> jk char(1),
-> -> temp_lahir varchar(100),
-> -> tgl_lahir date,
-> ;
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 'tabke
nama(
-> nim varchar(10),
-> nama varchar(100),
-> jk char(1),' at line 1
MariaDB [kuliah]> create table nama(
-> nim varchar(10),
-> nama varchar(100),
-> jk char(1),
-> temp_lahir varchar(100),
-> tgl_lahir date,
-> primary key (nim));
Query OK, 0 rows affected (0.025 sec)

MariaDB [kuliah]> show tables;


+------------------+
| Tables_in_kuliah |
+------------------+
| nama |
+------------------+
1 row in set (0.001 sec)

MariaDB [kuliah]> create table matkul(


-> kd_matkul varchar(100),
-> nama varchar(100),
-> sks int(2),
-> primary key (kd_matkul));
Query OK, 0 rows affected (0.021 sec)
MariaDB [kuliah]> show tables;
+------------------+
| Tables_in_kuliah |
+------------------+
| matkul |
| nama |
+------------------+
2 rows in set (0.001 sec)

MariaDB [kuliah]> ; create table mhs_matkul(


ERROR: No query specified

-> ;
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 '' at
line 1
MariaDB [kuliah]> create table mhs_matkul(
-> id_mhs_matkul int (5),
-> nim varchar(10),
-> kd_matkul varchar(10),
-> foregn key(nim) references nama(nim);
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
'key(nim) references nama(nim)' at line 5
MariaDB [kuliah]> create table mhs_matkul(
-> id_mhs_matkul int (5),
-> nim varchar(10),
-> kd_matkul varchar(10),
-> foregn key(nim) references nama(nim));
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
'key(nim) references nama(nim))' at line 5
MariaDB [kuliah]> create table mhs_matkul(
-> id_mhs_matkul int (5),
-> nim varchar(10),c
-> ;
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 '' at
line 3
MariaDB [kuliah]> create table mhs_matkul(
-> id_mhs_matkul int (5),
-> nim varchar(10),
-> kd_matkul varchar(10),
-> foreign key(nim) references nama(nim));
Query OK, 0 rows affected (0.028 sec)

MariaDB [kuliah]> alter table mhs_matkul add constrain fk_terserah foreign


key(kd_matkul) references maatkul(kd_matkul);
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
'fk_terserah foreign key(kd_matkul) references maatkul(kd_matkul)' at line 1
MariaDB [kuliah]> alter table mhs_matkul add constrain fk_terserah foreign
key(kd_matkul) references matkul(kd_matkul);
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
'fk_terserah foreign key(kd_matkul) references matkul(kd_matkul)' at line 1
MariaDB [kuliah]> alter table mhs_matkul add constrain fk_terserah foreign
key(kd_matkul) references maatkul(kd_matkul);
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
'fk_terserah foreign key(kd_matkul) references maatkul(kd_matkul)' at line 1
MariaDB [kuliah]> alter table mhs_matkul add constrain fk_terserah foreign
key(kd_matkul) references matkul(kd_matkul);
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
'fk_terserah foreign key(kd_matkul) references matkul(kd_matkul)' at line 1
MariaDB [kuliah]> use kuliah;
Database changed
MariaDB [kuliah]> alter table mhs_matkul add constrain fk_terserah foreign
key(kd_matkul) references matkul(kd_matkul);
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
'fk_terserah foreign key(kd_matkul) references matkul(kd_matkul)' at line 1
MariaDB [kuliah]> alter table mhs_matkul add foreign key(kd_matkul) references
matkul(kd_matkul);
Query OK, 0 rows affected (0.100 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [kuliah]> insert into nama values('1911522007','Intan','p','Tanjung


Barulak','2001-07-29');
Query OK, 1 row affected (0.008 sec)

MariaDB [kuliah]> insert into nama


values('1911521010','Ulfa','p','Bukittinggi','2001-08-12');
Query OK, 1 row affected (0.003 sec)

MariaDB [kuliah]> insert into matkul values ('IPS','Pratikum Struktur Data dan
Algoritma');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [kuliah]> insert into matkul values ('IPS','Pratikum Struktur Data dan
Algoritma',2);
Query OK, 1 row affected (0.004 sec)

MariaDB [kuliah]> insert into matkul values ('IPA','Dasar-Dasar Manajemen',2);


Query OK, 1 row affected (0.004 sec)

MariaDB [kuliah]> select * from nama;


+------------+-------+------+-----------------+------------+
| nim | nama | jk | temp_lahir | tgl_lahir |
+------------+-------+------+-----------------+------------+
| 1911521010 | Ulfa | p | Bukittinggi | 2001-08-12 |
| 1911522007 | Intan | p | Tanjung Barulak | 2001-07-29 |
+------------+-------+------+-----------------+------------+
2 rows in set (0.000 sec)

MariaDB [kuliah]> select * form nama where nim = '1911521010';


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 'form
nama where nim = '1911521010'' at line 1
MariaDB [kuliah]> select * from nama where nim = '1911521010';
+------------+------+------+-------------+------------+
| nim | nama | jk | temp_lahir | tgl_lahir |
+------------+------+------+-------------+------------+
| 1911521010 | Ulfa | p | Bukittinggi | 2001-08-12 |
+------------+------+------+-------------+------------+
1 row in set (0.000 sec)
MariaDB [kuliah]> select * from nama where nama LIKE 'i%';
+------------+-------+------+-----------------+------------+
| nim | nama | jk | temp_lahir | tgl_lahir |
+------------+-------+------+-----------------+------------+
| 1911522007 | Intan | p | Tanjung Barulak | 2001-07-29 |
+------------+-------+------+-----------------+------------+
1 row in set (0.001 sec)

MariaDB [kuliah]> select nim,nama from nama;


+------------+-------+
| nim | nama |
+------------+-------+
| 1911521010 | Ulfa |
| 1911522007 | Intan |
+------------+-------+
2 rows in set (0.001 sec)

MariaDB [kuliah]> select * from matkul;


+-----------+--------------------------------------+------+
| kd_matkul | nama | sks |
+-----------+--------------------------------------+------+
| IPA | Dasar-Dasar Manajemen | 2 |
| IPS | Pratikum Struktur Data dan Algoritma | 2 |
+-----------+--------------------------------------+------+
2 rows in set (0.001 sec)

MariaDB [kuliah]> select * from matkul kd_matkul = 'IPA';


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 '=
'IPA'' at line 1
MariaDB [kuliah]> select * form matkul where kd_matkul = 'IPA';
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 'form
matkul where kd_matkul = 'IPA'' at line 1
MariaDB [kuliah]> select * from matkul where kd_matkul = 'IPA';
+-----------+-----------------------+------+
| kd_matkul | nama | sks |
+-----------+-----------------------+------+
| IPA | Dasar-Dasar Manajemen | 2 |
+-----------+-----------------------+------+
1 row in set (0.000 sec)

MariaDB [kuliah]> select from matkul where kd_matkul LIKE 'i%';


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 'from
matkul where kd_matkul LIKE 'i%'' at line 1
MariaDB [kuliah]> select from matkul where kd_matkul LIKE 'I%';
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 'from
matkul where kd_matkul LIKE 'I%'' at line 1
MariaDB [kuliah]> select *from makul where kd_matkul LIKE 'I%';
ERROR 1146 (42S02): Table 'kuliah.makul' doesn't exist
MariaDB [kuliah]> select * from matkul where kd_matkul LIKE 'I%';
+-----------+--------------------------------------+------+
| kd_matkul | nama | sks |
+-----------+--------------------------------------+------+
| IPA | Dasar-Dasar Manajemen | 2 |
| IPS | Pratikum Struktur Data dan Algoritma | 2 |
+-----------+--------------------------------------+------+
2 rows in set (0.001 sec)

MariaDB [kuliah]> update from mahasiswa set nim = '1911521020' where nim =
'1911521010';
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 'from
mahasiswa set nim = '1911521020' where nim = '1911521010'' at line 1
MariaDB [kuliah]> update * from mahasiswa set nim = '1911521020' where nim =
'1911521010';
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 '* from
mahasiswa set nim = '1911521020' where nim = '1911521010'' at line 1
MariaDB [kuliah]> update from mahasiswa set nim = '1911521020' where nim =
'1911521010';
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 'from
mahasiswa set nim = '1911521020' where nim = '1911521010'' at line 1
MariaDB [kuliah]> update from nama set nim = '1911521020' where nim =
'1911521010';
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 'from
nama set nim = '1911521020' where nim = '1911521010'' at line 1
MariaDB [kuliah]> update nama set nim = '1911521020' where nim = '1911521010';
Query OK, 1 row affected (0.004 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [kuliah]> update nama set tgl_lahir = '2020-10-02' where tgl_lahir = '2001-
07-29';
Query OK, 1 row affected (0.003 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [kuliah]> select * from mhs_matkul;


+---------------+------------+-----------+
| id_mhs_matkul | nim | kd_matkul |
+---------------+------------+-----------+
| NULL | NULL | NULL |
| 1 | 1911522007 | IPA |
+---------------+------------+-----------+
2 rows in set (0.001 sec)

MariaDB [kuliah]> nama.nim, nama.nama, matkul.nama from nama join mhs_matkul on


nama.nim = mhs_matkul.nim;
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
'nama.nim, nama.nama, matkul.nama from nama join mhs_matkul on nama.nim = mhs_mat'
at line 1
MariaDB [kuliah]> select nama.nim, nama.nama, matkul.nama from nama join
mhs_matkul on nama.nim = mhs_matkul.nim;
ERROR 1054 (42S22): Unknown column 'matkul.nama' in 'field list'
MariaDB [kuliah]> select nama.nim, nama.nama, matkul.nama from nama join mhs_matkul
on nama.nim = mhs_matkul.nim join matkul on mhs_matkul.kd_matkul =
matkul.kd_matkul;
+------------+-------+-----------------------+
| nim | nama | nama |
+------------+-------+-----------------------+
| 1911522007 | Intan | Dasar-Dasar Manajemen |
+------------+-------+-----------------------+
1 row in set (0.001 sec)
MariaDB [kuliah]> select nama.nim, nama.nama, matkul.nama from mhs_matkul join nama
on nama.nim = mhs_matkul.nim join matkul on mhs_matkul.kd_matkul =
matkul.kd_matkul;
+------------+-------+-----------------------+
| nim | nama | nama |
+------------+-------+-----------------------+
| 1911522007 | Intan | Dasar-Dasar Manajemen |
+------------+-------+-----------------------+
1 row in set (0.001 sec)

MariaDB [kuliah]> select count (sks) as jumlah_sks from matkul;


ERROR 1630 (42000): FUNCTION kuliah.count does not exist. Check the 'Function Name
Parsing and Resolution' section in the Reference Manual
MariaDB [kuliah]> selectcount (sks) as jumlah_sks from matkul;
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
'selectcount (sks) as jumlah_sks from matkul' at line 1
MariaDB [kuliah]> Bye
Ctrl-C -- exit!

C:\xampp\mysql\bin>selectcount (sks) as jumlah_sks from matkul;


'selectcount' is not recognized as an internal or external command,
operable program or batch file.

C:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 179
Server version: 10.4.10-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)]> use kuliah


Database changed
MariaDB [kuliah]> select count(sks) as jumlah_sks from matkul;
+------------+
| jumlah_sks |
+------------+
| 2 |
+------------+
1 row in set (0.000 sec)

MariaDB [kuliah]> select nama,nim from nama union;


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 '' at
line 1
MariaDB [kuliah]> select nama.nim, nama.nama, matkul.nama from nama join
mhs_matkul on nama.nim = mhs_matkul.nim;

Potrebbero piacerti anche