0% found this document useful (0 votes)
27 views6 pages

Database Mysql Day 1

The document shows the steps of connecting to a MariaDB database server using MySQL, creating a database called "mhs", creating a table within that database called "db_mhs" with fields for student ID, name, gender, and other attributes, and inserting two records into the table.

Uploaded by

Teguh Pambudi
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)
27 views6 pages

Database Mysql Day 1

The document shows the steps of connecting to a MariaDB database server using MySQL, creating a database called "mhs", creating a table within that database called "db_mhs" with fields for student ID, name, gender, and other attributes, and inserting two records into the table.

Uploaded by

Teguh Pambudi
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/ 6

Microsoft Windows [Version 10.0.22000.

1219]

(c) Microsoft Corporation. All rights reserved.

C:\Users\teguh>cd c:/

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 9

Server version: 10.4.25-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 |

+--------------------+

| db_mhs |

| information_schema |

| mysql |

| performance_schema |

| phpmyadmin |

| test |

+--------------------+

6 rows in set (0.001 sec)


MariaDB [(none)]> create database mhs;

Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| db_mhs |

| information_schema |

| mhs |

| mysql |

| performance_schema |

| phpmyadmin |

| test |

+--------------------+

7 rows in set (0.001 sec)

MariaDB [(none)]> drop database mhs;

Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| db_mhs |

| information_schema |

| mysql |

| performance_schema |
| phpmyadmin |

| test |

+--------------------+

6 rows in set (0.001 sec)

MariaDB [(none)]> create database mhs;

Query OK, 1 row affected (0.012 sec)

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| db_mhs |

| information_schema |

| mhs |

| mysql |

| performance_schema |

| phpmyadmin |

| test |

+--------------------+

7 rows in set (0.001 sec)

MariaDB [(none)]> use mhs;

Database changed

MariaDB [mhs]> create table db_mhs(no int(4));

Query OK, 0 rows affected (0.025 sec)

MariaDB [mhs]> select*from db_mhs;

Empty set (0.001 sec)


MariaDB [mhs]> alter table db_mhs add npm char(13);

Query OK, 0 rows affected (0.019 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [mhs]> alter table db_mhs add nama varchar(50);

Query OK, 0 rows affected (0.017 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [mhs]> desc db_mhs;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| no | int(4) | YES | | NULL | |

| npm | char(13) | YES | | NULL | |

| nama | varchar(50) | YES | | NULL | |

+-------+-------------+------+-----+---------+-------+

3 rows in set (0.015 sec)

MariaDB [mhs]> alter table db_mhs add jenis_kelamin varchar(10);

Query OK, 0 rows affected (0.017 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [mhs]> desc db_mhs;

+---------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+

| no | int(4) | YES | | NULL | |

| npm | char(13) | YES | | NULL | |


| nama | varchar(50) | YES | | NULL | |

| jenis_kelamin | varchar(10) | YES | | NULL | |

+---------------+-------------+------+-----+---------+-------+

4 rows in set (0.014 sec)

MariaDB [mhs]> select*from db_mhs;

Empty set (0.000 sec)

MariaDB [mhs]> insert into db_mhs values('1','2110631230021','teguh pambudi','laki laki');

Query OK, 1 row affected (0.013 sec)

MariaDB [mhs]> select*from db_mhs;

+------+---------------+---------------+---------------+

| no | npm | nama | jenis_kelamin |

+------+---------------+---------------+---------------+

| 1 | 2110631230021 | teguh pambudi | laki laki |

+------+---------------+---------------+---------------+

1 row in set (0.001 sec)

MariaDB [mhs]> insert into db_mhs values('2','2110631230022','bukan teguh pambudi','wanita');

Query OK, 1 row affected (0.014 sec)

MariaDB [mhs]> select*from db_mhs;

+------+---------------+---------------------+---------------+

| no | npm | nama | jenis_kelamin |

+------+---------------+---------------------+---------------+

| 1 | 2110631230021 | teguh pambudi | laki laki |

| 2 | 2110631230022 | bukan teguh pambudi | wanita |

+------+---------------+---------------------+---------------+
2 rows in set (0.000 sec)

MariaDB [mhs]>

You might also like