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

Belajar Mysql

The document shows the steps taken to connect to a MySQL database named "MariaDB" using the command line. It then proceeds to create a new database called "UBSI" and a table within it called "MAHASISWA". Several alterations are made to the table structure through renaming, changing data types, and modifying fields. Finally, some data is inserted into the table and selected.
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)
13 views4 pages

Belajar Mysql

The document shows the steps taken to connect to a MySQL database named "MariaDB" using the command line. It then proceeds to create a new database called "UBSI" and a table within it called "MAHASISWA". Several alterations are made to the table structure through renaming, changing data types, and modifying fields. Finally, some data is inserted into the table and selected.
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

C:\Users\asus>cd..

C:\Users>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 9
Server version: 10.4.27-MariaDB mariadb.org binary distribution

MariaDB [(none)]> show databases;


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

MariaDB [(none)]> select curdate();


+------------+
| curdate() |
+------------+
| 2023-06-08 |
+------------+
1 row in set (0.000 sec)

MariaDB [(none)]> select curtime();


+-----------+
| curtime() |
+-----------+
| 20:18:41 |
+-----------+
1 row in set (0.001 sec)

MariaDB [(none)]> select now();


+---------------------+
| now() |
+---------------------+
| 2023-06-08 20:18:57 |
+---------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> create database UBSI;


Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
| ubsi |
+--------------------+
6 rows in set (0.001 sec)
MariaDB [(none)]> use UBSI;
Database changed
MariaDB [UBSI]> create table MAHASISWA(
-> NIM int(10) not null,
-> NAMA varchar(20) not null,
-> ALAMAT varchar(30) not null,
-> primary key(NIM)
-> );
Query OK, 0 rows affected (0.049 sec)

MariaDB [UBSI]> describe mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| NIM | int(10) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| ALAMAT | varchar(30) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.029 sec)

MariaDB [UBSI]> alter table mahasiswa


-> rename dosen;
Query OK, 0 rows affected (0.046 sec)

MariaDB [UBSI]> describe dosen;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| NIM | int(10) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| ALAMAT | varchar(30) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.030 sec)

MariaDB [UBSI]> alter table dosen


-> rename mahasiswa;
Query OK, 0 rows affected (0.021 sec)

MariaDB [UBSI]> describe mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| NIM | int(10) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| ALAMAT | varchar(30) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.010 sec)

MariaDB [UBSI]> alter table mahasiswa


-> change nim nip int(15) not null;
Query OK, 0 rows affected (0.023 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [UBSI]> describe mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| nip | int(15) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| ALAMAT | varchar(30) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.017 sec)

MariaDB [UBSI]> alter table mahasiswa


-> change nip NIM int(10) not null;
Query OK, 0 rows affected (0.012 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [UBSI]> describe mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| NIM | int(10) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| ALAMAT | varchar(30) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.024 sec)

MariaDB [UBSI]> alter table mahasiswa


-> modify Alamat varchar(40) not null;
Query OK, 0 rows affected (0.021 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [UBSI]> describe mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| NIM | int(10) | NO | PRI | NULL | |
| NAMA | varchar(20) | NO | | NULL | |
| Alamat | varchar(40) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.025 sec)

MariaDB [UBSI]> insert into mahasiswa (NIM,Nama,Alamat)


-> values
-> (17207024,"Abi Mutholib","Jl.Tegalsari Timur No. 3"),
-> (17207025,"Faris Maulana","Jl. Ciracas Barat no. 7"),
-> (17207027,"Akhmad Zaeni","Jl. Depok Barat No. 9");
Query OK, 3 rows affected (0.013 sec)
Records: 3 Duplicates: 0 Warnings: 0

MariaDB [UBSI]> select*from mahasiswa;


+----------+---------------+--------------------------+
| NIM | NAMA | Alamat |
+----------+---------------+--------------------------+
| 17207024 | Abi Mutholib | Jl.Tegalsari Timur No. 3 |
| 17207025 | Faris Maulana | Jl. Ciracas Barat no. 7 |
| 17207027 | Akhmad Zaeni | Jl. Depok Barat No. 9 |
+----------+---------------+--------------------------+
3 rows in set (0.000 sec)

MariaDB [UBSI]>update mahasiswa

belajar.....

You might also like