Di tutorial sebelumnya teah dijelaskan cara membuat database, tabel, dan relasi antar tabel. Pada tutorial ini akan disertakan cara mengisi tabel-tabel tersebut dengan berbagai macam data yang diperlukan. Command MySQL dan hasil keluarannya akan ditampilkan pada bagian-bagian sebagai berikut :
1). Memasukkan Data pada Tabel “ME”
<strong>
mysql> insert into ME values(1001, 'George', 'Washington', 'Presiden Amerika I'); Query OK, 1 row affected (0.27 sec) mysql> insert into ME values(1002, 'John', 'Adams', 'Presiden Amerika II'); Query OK, 1 row affected (0.25 sec) mysql> insert into ME values(1003, 'Thomas', 'Jefferson', 'Presiden Amerika III'); Query OK, 1 row affected (0.02 sec) mysql> insert into ME values(1004, 'James', 'Madison', 'Presiden Amerika IV'); Query OK, 1 row affected (0.03 sec) mysql> insert into ME values(1005, 'James', 'Monroe', 'Presiden Amerika V'); Query OK, 1 row affected (0.05 sec) mysql> select *from ME; +-------+------------+------------+----------------------+ | my_id | first_name | last_name | other_details | +-------+------------+------------+----------------------+ | 1001 | George | Washington | Presiden Amerika I | | 1002 | John | Adams | Presiden Amerika II | | 1003 | Thomas | Jefferson | Presiden Amerika III | | 1004 | James | Madison | Presiden Amerika IV | | 1005 | James | Monroe | Presiden Amerika V | +-------+------------+------------+----------------------+ 5 rows in set (0.09 sec)
2). Memasukkan Data pada Tabel “SOCIAL_NETWORKS”
mysql> insert into SOCIAL_NETWORKS values(696318116, 'www.facebook.com', 'Facebook'); Query OK, 1 row affected (0.27 sec) mysql> insert into SOCIAL_NETWORKS values(16814316, 'www.twitter.com', 'Twitter'); Query OK, 1 row affected (0.27 sec) mysql> insert into SOCIAL_NETWORKS values(209111681, 'www.friendster.com', 'Friendster'); Query OK, 1 row affected (0.27 sec) mysql> insert into SOCIAL_NETWORKS values(741201211, 'www.plurk.com', 'Plurk'); Query OK, 1 row affected (0.27 sec) mysql> select *from SOCIAL_NETWORKS; +--------------+--------------------+---------------------+ | network_code | network_name | network_description | +--------------+--------------------+---------------------+ | 168143162 | www.twitter.com | Twitter | | 209111681 | www.friendster.com | Friendster | | 696318116 | www.facebook.com | Facebook | | 741201211 | www.plurk.com | Plurk | +--------------+--------------------+---------------------+ 4 rows in set (0.01 sec)
3). Memasukkan Data pada Tabel “MY_EMAIL_LOGINS”
mysql> insert into MY_EMAIL_LOGINS values('gwashington', 1001, 696318116, ‘2009-12-19’
009, 'thomas_jefferson@gmail.com', 'jefferson03', 'Alamat email T. Jefferson');
Query OK, 1 row affected (0.02 sec)
mysql> insert into MY_EMAIL_LOGINS values('jadams', 1002, 696318116, ‘2009-12-20’
9, 'james_madison@gmail.com', 'madison04', 'Alamat email J. Madison');
Query OK, 1 row affected (0.03 sec)
mysql> insert into MY_EMAIL_LOGINS values('tjefferson', 1003, 696318116, ‘2009-12-21’, 'thomas_jefferson@gmail.com', 'jefferson03', 'Alamat email T. Jefferson');
Query OK, 1 row affected (0.02 sec)
mysql> insert into MY_EMAIL_LOGINS values('jmadison', 1004, 696318116, ‘2009-12-20’, 'james_madison@gmail.com', 'madison04', 'Alamat email J. Madison');
Query OK, 1 row affected (0.03 sec)
mysql> insert into MY_EMAIL_LOGINS values('jmonroe', 1005, 696318116, ‘2009-12-19’, 'john_monroe@gmail.com', 'monroe_05', 'Alamat email J. Monroe');
Query OK, 1 row affected (0.06 sec)
mysql> select *from MY_EMAIL_LOGINS;
+-------------+-------+--------------+----------------+-------------------------
----+-------------------+----------------------------+
| my_login | my_id | network_code | date_signed_up | my_email_name
| my_email_password | other_details |
+-------------+-------+--------------+----------------+-------------------------
----+-------------------+----------------------------+
| gwashington | 1001 | 696318116 | 2009-12-19 | george_washington@gmail.
com | washington01 | Alamat email G. Washington |
| jadams | 1002 | 696318116 | 2009-12-20 | john_adams@gmail.com
| adams02 | Alamat email J. Adams |
| jmadison | 1004 | 696318116 | 2009-12-21 | james_madison@gmail.com
| madison04 | Alamat email J. Madison |
| jmonroe | 1005 | 696318116 | 2009-12-20 | john_monroe@gmail.com
| monroe_05 | Alamat email J. Monroe |
| tjefferson | 1003 | 696318116 | 2009-12-19 | thomas_jefferson@gmail.c
om | jefferson03 | Alamat email T. Jefferson |
+-------------+-------+--------------+----------------+-------------------------
----+-------------------+----------------------------+
5 rows in set (0.00 sec)
4). Memasukkan Data pada Tabel “MY_BOXES”
mysql> insert into SENT_MESSAGES values ('001', 'gwashington', '2009-12-19', 'ja
mes_monroe@gmail.com', 'Greeting', 'Good night, Sir', '');
Query OK, 1 row affected (0.08 sec)
mysql> insert into SENT_MESSAGES values ('002', 'gwashington', '2009-12-19', 'jo
hn_adams@gmail.com', 'Introduction', 'Nice to meet you', '');
Query OK, 1 row affected (0.05 sec)
mysql> select *from SENT_MESSAGES;
+------------+-------------+------------+------------------------+--------------
+------------------+---------------+
| message_id | my_login | date_sent | to_email_address | subject
| message | other_details |
+------------+-------------+------------+------------------------+--------------
+------------------+---------------+
| 001 | gwashington | 2009-12-19 | james_monroe@gmail.com | Greeting
| Good night, Sir | |
| 002 | gwashington | 2009-12-19 | john_adams@gmail.com | Introduction
| Nice to meet you | |
+------------+-------------+------------+------------------------+--------------
+------------------+---------------+
2 rows in set (0.00 sec)
5). Memasukkan Data pada Tabel “NOTIFICATIONS”
mysql> insert into NOTIFICATIONS values ('001', 'gwashington', '2009-12-19', 'Up
date Status', 'Staying at home...', '');
Query OK, 1 row affected (0.27 sec)
mysql> insert into NOTIFICATIONS values ('002', 'gwashington', '2009-12-20', 'Up
date Status', 'have a nice day...', '');
Query OK, 1 row affected (0.05 sec)
mysql> select *from NOTIFICATIONS;
+-----------------+-------------+---------------+---------------+---------------
-----+---------------+
| notification_id | my_login | date_received | subject | message
| other_details |
+-----------------+-------------+---------------+---------------+---------------
-----+---------------+
| 001 | gwashington | 2009-12-19 | Update Status | Staying at hom
e... | |
| 002 | gwashington | 2009-12-20 | Update Status | have a nice da
y... | |
+-----------------+-------------+---------------+---------------+---------------
-----+---------------+
6). Memasukkan Data pada Tabel “UPDATES”
mysql> insert into UPDATES values ('001', 'gwashington', '2009-12-22', 'Update S
tatus', 'Having a dinner', '');
Query OK, 1 row affected (0.08 sec)
mysql> insert into UPDATES values ('002', 'gwashington', '2009-12-22', 'Update S
tatus', 'Time to sleep', '');
Query OK, 1 row affected (0.03 sec)
mysql> select *from UPDATES;
+-----------+-------------+---------------+---------------+-----------------+---
------------+
| update_id | my_login | date_received | subject | message | ot
her_details |
+-----------+-------------+---------------+---------------+-----------------+---
------------+
| 001 | gwashington | 2009-12-22 | Update Status | Having a dinner |
|
| 002 | gwashington | 2009-12-22 | Update Status | Time to sleep |
|
+-----------+-------------+---------------+---------------+-----------------+---
------------+
2 rows in set (0.00 sec)
Pada tutorial selanjutnya, akan diberikan cara melakukan operasi Query pada MySQL. Semoga bermanfaat…
Komentar