0% found this document useful (0 votes)
37 views7 pages

Praktikum Sistem Basis Data: Nama: Wanson Bernando Silalahi NPM: 217510021

The document describes creating and modifying tables in a MySQL database called "test". Several tables are created - tbl_mhs, dosen, matakuliah, and pegawai. The tbl_mhs table is initially created as tbl_mahasiswa and later renamed. Columns are added and dropped from tables as needed.

Uploaded by

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

Praktikum Sistem Basis Data: Nama: Wanson Bernando Silalahi NPM: 217510021

The document describes creating and modifying tables in a MySQL database called "test". Several tables are created - tbl_mhs, dosen, matakuliah, and pegawai. The tbl_mhs table is initially created as tbl_mahasiswa and later renamed. Columns are added and dropped from tables as needed.

Uploaded by

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

PRAKTIKUM SISTEM BASIS DATA

NAMA : WANSON BERNANDO SILALAHI

NPM : 217510021

FAKULTAS ILMU KOMPUTER


UNIVERSITAS METHODIST INDONESIA
TA.2017/2018
Microsoft Windows [Version 10.0.10586]

(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\WIN 10>cd\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 10

Server version: 10.1.25-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use test;

Database changed

MariaDB [test]> create table tbl_mahasiswa(npm int(9) not null primary key,

-> nama varchar(30) not null,

-> jenkel varchar(20) not null,

-> jurusan varchar(20) not null,

-> alamat varchar(30) not null);

ERROR 1050 (42S01): Table 'tbl_mahasiswa' already exists

MariaDB [test]> show tables;

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

| Tables_in_test |

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

| tbl_dosen |

| tbl_mahasiswa |

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

2 rows in set (0.00 sec)


MariaDB [test]> create table matakuliah(kode_matkul int(20) not null primary key,

-> nama varchar(30) not null,

-> sks int (9) not null);

Query OK, 0 rows affected (0.20 sec)

MariaDB [test]> create table pegawai(nidn int(20) not null primary key,

-> nama varchar(30) not null,

-> jenkel varchar(30) not null,

-> jabatan varchar(30) not null,

-> alamat varchar(30) not null);

Query OK, 0 rows affected (0.17 sec)

MariaDB [test]> create table dosen(nidn int(20) not null primary key,

-> nama varchar(30) not null,

-> jenkel varchar(30) not null,

-> jabatan varchar(30) not null,

-> alamat varchar(30) not null);

Query OK, 0 rows affected (0.26 sec)

MariaDB [test]> show tables;

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

| Tables_in_test |

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

| dosen |

| matakuliah |

| pegawai |

| tbl_dosen |

| tbl_mahasiswa |

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

5 rows in set (0.00 sec)


MariaDB [test]> desc tbl_mahasiswa;

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

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

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

| npm | int(9) | NO | PRI | NULL | |

| nama | varchar(35) | NO | | NULL | |

| jenkel | varchar(15) | NO | | NULL | |

| jurusan | varchar(25) | NO | | NULL | |

| alamat | varchar(45) | NO | | NULL | |

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

5 rows in set (0.02 sec)

MariaDB [test]> desc tbl_dosen;

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

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

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

| nidn | int(9) | NO | PRI | NULL | |

| nama | varchar(35) | NO | | NULL | |

| jenkel | varchar(15) | NO | | NULL | |

| alamat | varchar(40) | NO | | NULL | |

| jurusan | varchar(20) | NO | | NULL | |

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

5 rows in set (0.01 sec)

MariaDB [test]> desc pegawai;

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

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

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

| nidn | int(20) | NO | PRI | NULL | |

| nama | varchar(30) | NO | | NULL | |


| jenkel | varchar(30) | NO | | NULL | |

| jabatan | varchar(30) | NO | | NULL | |

| alamat | varchar(30) | NO | | NULL | |

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

5 rows in set (0.01 sec)

MariaDB [test]> desc matakuliah;

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

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

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

| kode_matkul | int(20) | NO | PRI | NULL | |

| nama | varchar(30) | NO | | NULL | |

| sks | int(9) | NO | | NULL | |

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

3 rows in set (0.01 sec)

MariaDB [test]> rename table tbl_mahasiswa to tbl_mhs;

Query OK, 0 rows affected (0.22 sec)

MariaDB [test]> show tables;

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

| Tables_in_test |

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

| dosen |

| matakuliah |

| pegawai |

| tbl_dosen |

| tbl_mhs |

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

5 rows in set (0.00 sec)


MariaDB [test]> desc tbl_mhs;

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

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

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

| npm | int(9) | NO | PRI | NULL | |

| nama | varchar(35) | NO | | NULL | |

| jenkel | varchar(15) | NO | | NULL | |

| jurusan | varchar(25) | NO | | NULL | |

| alamat | varchar(45) | NO | | NULL | |

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

5 rows in set (0.01 sec)

MariaDB [test]> alter table tbl_mhs add email varchar(30);

Query OK, 0 rows affected (0.32 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [test]> desc tbl_mhs;

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

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

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

| npm | int(9) | NO | PRI | NULL | |

| nama | varchar(35) | NO | | NULL | |

| jenkel | varchar(15) | NO | | NULL | |

| jurusan | varchar(25) | NO | | NULL | |

| alamat | varchar(45) | NO | | NULL | |

| email | varchar(30) | YES | | NULL | |

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

6 rows in set (0.01 sec)

MariaDB [test]> drop table tbl_dosen;

Query OK, 0 rows affected (0.15 sec)


MariaDB [test]> show tables;

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

| Tables_in_test |

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

| dosen |

| matakuliah |

| pegawai |

| tbl_mhs |

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

4 rows in set (0.00 sec)

MariaDB [test]>

You might also like