PRAKTIKUM SISTEM MANAJEMEN BASIS DATA
MySQL
A. Langkah
– langkah program
1. Membuka
database dalam aplikasi mysql, apakah sudah ada database ‘phethouse’ atau
belum.
mysql>
show databases;
+--------------------+
|
Database |
+--------------------+
|
information_schema |
|
khusna |
|
mysql |
|
performance_schema |
|
sabil |
|
test |
+--------------------+
6
rows in set (0.25 sec)
2. Jika
tidak ada maka buatlah database ’pethouse’.
mysql>
create database pethouse;
Query
OK, 1 row affected (0.00 sec)
3. Lalu
dicek lagi apakah database ‘pethouse’ benar-benar sudah ada. Jika sudah ada
maka lanjut ke langkah berikutnya.
mysql>
show databases;
+--------------------+
|
Database |
+--------------------+
|
information_schema |
|
khusna |
|
mysql |
|
performance_schema |
|
pethouse |
|
sabil |
|
test |
+--------------------+
7
rows in set (0.01 sec)
4. Membuat
tabel ‘event’ dalam database ‘pethouse’.
mysql>
use pethouse;
Database
changed
mysql>
create table event(nama varchar(20), date date, type varchar(15), remark varchar(255));
Query
OK, 0 rows affected (0.15 sec)
5. Menampilkan
tabel yang ada di database ‘pethouse’.
mysql>
show tables;
+--------------------+
|
Tables_in_pethouse |
+--------------------+
|
event |
+--------------------+
1
row in set (0.00 sec)
6. Melihat
apakah tabel sudah sesuai dengan apa yang diinginkan.
mysql>
desc event;
+--------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| nama |
varchar(20) | YES | |
NULL | |
| date | date | YES
| | NULL |
|
| type |
varchar(15) | YES | |
NULL | |
| remark | varchar(255) | YES
| | NULL |
|
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.05 sec)
7. Mengisi
tabel ‘event’ dengan menggunakan INSERT.
mysql>
insert into event values('fluffy', '1995-05-15', 'litter', '4 kittens,3 female,
1 male');
Query
OK, 1 row affected (0.08 sec)
mysql>
insert into event values('buffy', '1993-06-23', 'litter', '5 puppies,2 female,3
male');
Query
OK, 1 row affected (0.07 sec)
mysql>
insert into event values('buffy', '1994-06-19', 'litter', '3 puppies,3 female');
Query
OK, 1 row affected (0.06 sec)
mysql>
insert into event values('chirpy', '1999-03-21', 'vet', 'needed beak straightened');
Query
OK, 1 row affected (0.05 sec)
8. Untuk
menampilkan data pada tabel ‘event’.
mysql>
select*from event;
+--------+------------+--------+----------------------------+
| nama | date | type
| remark |
+--------+------------+--------+----------------------------+
| fluffy | 1995-05-15 | litter | 4 kittens,3 female, 1 male |
| buffy | 1993-06-23 |
litter | 5 puppies,2 female,3 male |
| buffy | 1994-06-19 |
litter | 3 puppies,3 female |
| chirpy | 1999-03-21 | vet
| needed beak straightened |
+--------+------------+--------+----------------------------+
4 rows in set (0.00 sec)
9. Mengisi
tabel ‘event’ dengan menggunaka LOAD DATA
-
Buat data yang akan di isikan ke tabel
‘event’ pada Microsoft excel dan filenya di simpan dengan nama text(MS-DOS)
atau data yang di Microsoft excel dipindah pada notepad dan disave.
-
Misal disini nama filenya “ aq.txt ”
yang disave pada local computer E.
-
Isi datanya
-
Cara memasukan pada tabel ‘event’
mysql>
load data local infile 'E://aq.txt' into table event;
Query
OK, 6 rows affected, 11 warnings (0.07 sec)
Records:
6 Deleted: 0 Skipped: 0
Warnings: 11
mysql>
select*from event;
+----------+------------+------------+--------------------------
| nama | date | type | remark |
+----------+------------+------------+--------------------------
| fluffy | 1995-05-15
| litter | 4 kittens,3 female, 1
male |
| buffy | 1993-06-23
| litter | 5 puppies,2 female,3
male |
| buffy | 1994-06-19
| litter | 3 puppies,3 female |
| chirpy | 1999-03-21
| vet | needed beak
straightened |
| slim | 1997-08-03 | vet | broken rib
| bowser | 1991-10-12
| kennel |
| fang | 1991-10-12
| kennel |
| fang | 1998-08-28 | birthday
| gave him a new chew toy
| claws | 1998-03-17 | birthday
| gave him a nem flea collar
|whistler | 1998-12-09
| birthday | first birthday
+----------+------------+------------+--------------------------
16 rows in set (0.00 sec)
B.
Screenshot
program
Terima Kasih......
Tidak ada komentar:
Posting Komentar