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

Praktikum Basis Data 1

The document demonstrates how to use MySQL to create and manage a database and table. It shows how to create a new 'binfilm' database, make a table called 'infoprib' within that database to store actor information, insert and select data from that table. Various MySQL commands are used such as create, insert, select, show, describe to set up the database structure and populate the table with sample data.

Uploaded by

sengHansun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views4 pages

Praktikum Basis Data 1

The document demonstrates how to use MySQL to create and manage a database and table. It shows how to create a new 'binfilm' database, make a table called 'infoprib' within that database to store actor information, insert and select data from that table. Various MySQL commands are used such as create, insert, select, show, describe to set up the database structure and populate the table with sample data.

Uploaded by

sengHansun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Seng Hansun

723/Pra-MIK/122/2009
Kelas C
Pra S2 Ilmu Komputer
Universitas Gadjah Mada Yogyakarta
Tugas 1

Enter password: *****


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Menampilkan database yang ada

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

Membuat database baru dengan nama ‘binfilm’

mysql> create database binfilm;


Query OK, 1 row affected (0.03 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| binfilm |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
Menggunakan (membuka) database binfilm

mysql> use binfilm;


Database changed

Membuat tabel ‘infoprib’ (dalam database binfilm)

mysql> create table infoprib


-> (id_bin char(5),
-> nama char(25),
-> tgl_lahir date,
-> lokal char(1));
Query OK, 0 rows affected (0.08 sec)

Memasukkan data ke dalam tabel infoprib

mysql> insert into infoprib values


-> ('STONE','Sharon Stone','1958-03-10','T');
Query OK, 1 row affected (0.05 sec)

mysql> insert into infoprib


-> (id_bin, nama) values
-> ('DREWB','Drew Barrymore');
Query OK, 1 row affected (0.06 sec)

Menampilkan tabel yang ada (dalam database binfilm)

mysql> show tables;


+-------------------+
| Tables_in_binfilm |
+-------------------+
| infoprib |
+-------------------+
1 row in set (0.00 sec)

Melihat seluruh isi data dalam tabel infoprib

mysql> select * from infoprib;


+-------- +---------------- +------------ +-------+
| id_bin | nama | tgl_lahir | lokal |
+-------- +---------------- +------------ +-------+
| STONE | Sharon Stone | 1958-03-10 |T |
| DREWB | Drew Barrymore | NULL | NULL |
+-------- +---------------- +------------ +-------+
2 rows in set (0.00 sec)

Melihat struktur tabel

mysql> desc infoprib;


+----------- +---------- +------ +----- +--------- +-------+
| Field | Type | Null | Key | Default | Extra |
+----------- +---------- +------ +----- +--------- +-------+
| id_bin | char(5) | YES | | NULL | |
| nama | char(25) | YES | | NULL | |
| tgl_lahir | date | YES | | NULL | |
| lokal | char(1) | YES | | NULL | |
+----------- +---------- +------ +----- +--------- +-------+
4 rows in set (0.02 sec)

Menambah field ‘sex’ dalam tabel

mysql> alter table infoprib


-> add sex char(1);
Query OK, 2 rows affected (0.63 sec)
Records: 2 Duplicates: 0 Warnings: 0

Melihat struktur tabel

mysql> desc infoprib;


+----------- +---------- +------ +----- +--------- +-------+
| Field | Type | Null | Key | Default | Extra |
+----------- +---------- +------ +----- +--------- +-------+
| id_bin | char(5) | YES | | NULL | |
| nama | char(25) | YES | | NULL | |
| tgl_lahir | date | YES | | NULL | |
| lokal | char(1) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
+----------- +---------- +------ +----- +--------- +-------+
5 rows in set (0.05 sec)

Melihat seluruh isi data dalam tabel infoprib

mysql> select * from infoprib;


+-------- +---------------- +------------ +------- +------+
| id_bin | nama | tgl_lahir | lokal | sex |
+-------- +---------------- +------------ +------- +------+
| STONE | Sharon Stone | 1958-03-10 | T | NULL |
| DREWB | Drew Barrymore | NULL | NULL | NULL |
+-------- +---------------- +------------ +------- +------+
2 rows in set (0.00 sec)

mysql>

You might also like