0% found this document useful (0 votes)
14 views5 pages

Tugas Praktek Database Coba

1) The document describes setting up an XAMPP environment on Windows to use MySQL and creating a database named "coba" and table named "mahasiswa". 2) Several ALTER commands are used to modify the "mahasiswa" table by adding, removing, and changing columns. 3) The "mahasiswa" table is eventually renamed to "student".

Uploaded by

dzakky7716
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)
14 views5 pages

Tugas Praktek Database Coba

1) The document describes setting up an XAMPP environment on Windows to use MySQL and creating a database named "coba" and table named "mahasiswa". 2) Several ALTER commands are used to modify the "mahasiswa" table by adding, removing, and changing columns. 3) The "mahasiswa" table is eventually renamed to "student".

Uploaded by

dzakky7716
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/ 5

TUGAS PRAKTEK DATABASE COBA

Nama : Abyan Dzakky


NIM : 2205102067
Kelas : MI-3D

Setting environment for using XAMPP for Windows.


WENDRIA NOVA@LAPTOP-MN6QI4B2 d:\Program Files\xampp
# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.28-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 coba;


Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> use coba;


Database changed
MariaDB [coba]> create table mahasiswa;
ERROR 1113 (42000): A table must have at least 1 column
MariaDB [coba]>
MariaDB [coba]> create table mahasiswa(nama varchar(20) not null,alamat
varchar(20) not null);
Query OK, 0 rows affected (0.012 sec)

MariaDB [coba]> show tables;


+----------------+
| Tables_in_coba |
+----------------+
| mahasiswa |
+----------------+
1 row in set (0.000 sec)

MariaDB [coba]> desc mahasiswa;


+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| nama | varchar(20) | NO | | NULL | |
| alamat | varchar(20) | NO | | NULL | |
+--------+-------------+------+-----+---------+-------+
2 rows in set (0.154 sec)

MariaDB [coba]> alter table mahasiswa add keterangan varchar(15) not null;
Query OK, 0 rows affected (0.122 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> alter table mahasiswa add nim int(11) not null first;
Query OK, 0 rows affected (0.011 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [coba]> alter table mahasiswa add phone varchar(15) not null after
alamat;
Query OK, 0 rows affected (0.161 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> alter table mahasiswa modify nim char(11) not null;
Query OK, 0 rows affected (0.048 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> alter table mahasiswa change phone telephone varchar(20)


not null;
Query OK, 0 rows affected (0.013 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> alter table mahasiswa drop keterangan;


Query OK, 0 rows affected (0.084 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> rename table mahasiswa to student;


Query OK, 0 rows affected (0.236 sec)

MariaDB [coba]> alter table mahasiswa add primary key(nim);


ERROR 1146 (42S02): Table 'coba.mahasiswa' doesn't exist
MariaDB [coba]> alter table student add primary key(nim);
Query OK, 0 rows affected (0.032 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [coba]> desc student;


+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| nim | char(11) | NO | PRI | NULL | |
| nama | varchar(20) | NO | | NULL | |
| alamat | varchar(20) | NO | | NULL | |
| telephone | varchar(20) | NO | | NULL | |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.167 sec)

MariaDB [coba]>
LINK GOOGLE DRIVE :
https://drive.google.com/drive/folders/1TtgiXdugTE1NKDHehHz84236_ygkyI
dc?usp=sharing

You might also like