0% found this document useful (0 votes)
50 views9 pages

Buka CMD Ketik CD Ketik

The document shows the steps to create a database and tables using MySQL. It creates a database called "RentalDvd_11140605" and two tables called "tb_anggota" and "tb_dvd" to store member and DVD data. It then populates the tables with sample data and performs queries on the data.

Uploaded by

Rizky Nugroho
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)
50 views9 pages

Buka CMD Ketik CD Ketik

The document shows the steps to create a database and tables using MySQL. It creates a database called "RentalDvd_11140605" and two tables called "tb_anggota" and "tb_dvd" to store member and DVD data. It then populates the tables with sample data and performs queries on the data.

Uploaded by

Rizky Nugroho
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/ 9

Buka CMD

ketik cd c:\xampp\mysql\bin
ketik mysql -u root

ini dah masuk ke mysqlnya

mysql> create database RentalDvd_11140605;


Query OK, 1 row affected (0.00 sec)

mysql> use RentalDvd_11140605;


Database changed

mysql> create table tb_dvd (kddvd varchar(20) primary key, judulfilm varchar(10),
genre varchar(5), hargasewa int);
Query OK, 0 rows affected (0.03 sec)

mysql> create
varchar(20

table

tb_anggota(kdanggota

), alamat varchar (20), nohp varchar(12));


Query OK, 0 rows affected (0.05 sec)

varchar(5)

primary

key,

nama

mysql> desc tb_anggota;


+-----------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+-----------+-------------+------+-----+---------+-------+
| kdanggota | varchar(5) | NO | PRI | NULL

| nama

| varchar(20) | YES |

| NULL

| alamat

| varchar(20) | YES |

| NULL

| nohp

| varchar(12) | YES |

| NULL

+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

mysql> desc tb_dvd;


+-----------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+-----------+-------------+------+-----+---------+-------+
| kddvd

| varchar(20) | NO | PRI | NULL

| judulfilm | varchar(10) | YES |


| genre

| varchar(5) | YES |

| hargasewa | int(11)

| YES |

| NULL
| NULL
| NULL

|
|

|
|

+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> select * from tb_dvd;

Empty set (0.00 sec)

mysql> insert into


"0213837333");

tb_anggota

values("A0001",

"Indah

Karisma",

"Depok",

Query OK, 1 row affected (0.03 sec)

mysql> select * from tb_anggota;


+-----------+---------------+--------+------------+
| kdanggota | nama

| alamat | nohp

+-----------+---------------+--------+------------+
| A0001

| Indah Karisma | Depok | 0213837333 |

+-----------+---------------+--------+------------+
1 row in set (0.00 sec)

mysql> insert into tb_anggota


Minggu","08678346323");

values("A0002",

"Rani

Query OK, 1 row affected (0.02 sec)

mysql> select * from tb_anggota;


+-----------+----------------+--------------+-------------+
| kdanggota | nama

| alamat

| nohp

+-----------+----------------+--------------+-------------+
| A0001

| Indah Karisma | Depok

| 0213837333 |

| A0002

| Rani Ismayanti | Pasar Minggu | 08678346323 |

+-----------+----------------+--------------+-------------+
2 rows in set (0.00 sec)

Ismayanti",

"Pasar

mysql> insert
"08973836373");

into

tb_anggota

values("A0003",

"Adi

S",

"Semanggi",

mysql> select * from tb_anggota;


+-----------+----------------+--------------+-------------+
| kdanggota | nama

| alamat

| nohp

+-----------+----------------+--------------+-------------+
| A0001

| Indah Karisma | Depok

| A0002

| Rani Ismayanti | Pasar Minggu | 08678346323 |

| A0003

| Adi S

| Semanggi

| 0213837333 |

| 08973836373 |

+-----------+----------------+--------------+-------------+
3 rows in set (0.00 sec)

mysql> insert into tb_anggota values("A0004", "Rama", "Jakarta", "0813745372");


Query OK, 1 row affected (0.03 sec)

mysql> select * from tb_anggota;


+-----------+----------------+--------------+-------------+
| kdanggota | nama

| alamat

| nohp

+-----------+----------------+--------------+-------------+
| A0001

| Indah Karisma | Depok

| 0213837333 |

| A0002

| Rani Ismayanti | Pasar Minggu | 08678346323 |

| A0003

| Adi S

| Semanggi

| A0004

| Rama

| Jakarta

| 08973836373 |
| 0813745372 |

+-----------+----------------+--------------+-------------+
4 rows in set (0.00 sec)

mysql> alter table tb_dvd rename tabel_dvd;


Query OK, 0 rows affected (0.02 sec)

mysql> show tables;


+------------------------------+
| Tables_in_rentaldvd_11140605 |
+------------------------------+
| tabel_dvd

| tb_anggota

+------------------------------+
2 rows in set (0.00 sec)

mysql> alter table tabel_dvd add produksi varchar(20) after genre;


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

mysql> show tables;


+------------------------------+
| Tables_in_rentaldvd_11140605 |
+------------------------------+
| tabel_dvd

| tb_anggota

+------------------------------+
2 rows in set (0.00 sec)

mysql> desc tabel_dvd;

+-----------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+-----------+-------------+------+-----+---------+-------+
| kddvd

| varchar(20) | NO | PRI | NULL

| judulfilm | varchar(10) | YES |


| genre

| varchar(5) | YES |

| produksi | varchar(20) | YES |


| hargasewa | int(11)

| YES |

| NULL
| NULL

|
|

|
|

| NULL
| NULL

|
|

|
|

+-----------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> select * from tabel_dvd;


Empty set (0.00 sec)

mysql> alter table tabel_dvd modify kddvd char(5);


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

mysql> insert into tabel_dvd values("D0001","Twilight New", "Drama", "Summit Ent


ertainment", "10000");
Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> insert into tabel_dvd values("D0002","Selendang Rocker", "Komedi",


"Sinemart", "15000");
Query OK, 1 row affected, 2 warnings (0.03 sec)

mysql> insert into tabel_dvd values("D0003","2012", "Action", "Columbia Pictures",


"20000");
Query OK, 1 row affected, 1 warning (0.03 sec)

mysql> insert into tabel_dvd values("D0004","Laskar Pelangi", "Drama", "Miles


Production", "15000");
Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> update tabel_dvd set hargasewa=25000 where kddvd="D0003";


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from tabel_dvd;


+-------+------------+-------+----------------------+-----------+
| kddvd | judulfilm | genre | produksi

| hargasewa |

+-------+------------+-------+----------------------+-----------+
| D0001 | Twilight N | Drama | Summit Entertainment |
| D0002 | Selendang | Komed | Sinemart
| D0003 | 2012

| Actio | Columbia Pictures

| D0004 | Laskar Pel | Drama | Miles Production

15000 |

25000 |
|

15000 |

+-------+------------+-------+----------------------+-----------+
4 rows in set (0.00 sec)

mysql> delete from tabel_dvd where kddvd="D0002";


Query OK, 1 row affected (0.03 sec)

mysql> select * from tabel_dvd;

10000 |

+-------+------------+-------+----------------------+-----------+
| kddvd | judulfilm | genre | produksi

| hargasewa |

+-------+------------+-------+----------------------+-----------+
| D0001 | Twilight N | Drama | Summit Entertainment |
| D0003 | 2012

| Actio | Columbia Pictures

| D0004 | Laskar Pel | Drama | Miles Production

10000 |

25000 |
|

15000 |

+-------+------------+-------+----------------------+-----------+
3 rows in set (0.00 sec)

mysql> select * from tabel_dvd;


+-------+------------+-------+----------------------+-----------+
| kddvd | judulfilm | genre | produksi

| hargasewa |

+-------+------------+-------+----------------------+-----------+
| D0001 | Twilight N | Drama | Summit Entertainment |
| D0003 | 2012

| Actio | Columbia Pictures

| D0004 | Laskar Pel | Drama | Miles Production

10000 |

25000 |
|

15000 |

+-------+------------+-------+----------------------+-----------+
3 rows in set (0.00 sec)

mysql> select * from tabel_dvd where hargasewa="15000";


+-------+------------+-------+------------------+-----------+
| kddvd | judulfilm | genre | produksi

| hargasewa |

+-------+------------+-------+------------------+-----------+
| D0004 | Laskar Pel | Drama | Miles Production |
+-------+------------+-------+------------------+-----------+
1 row in set (0.00 sec)

15000 |

mysql> select kddvd, judulfilm, hargasewa from tabel_dvd where genre="drama";


+-------+------------+-----------+
| kddvd | judulfilm | hargasewa |
+-------+------------+-----------+
| D0001 | Twilight N |

10000 |

| D0004 | Laskar Pel |

15000 |

+-------+------------+-----------+
2 rows in set (0.00 sec)

mysql> select * from tabel_dvd where hargasewa<10000;


Empty set (0.00 sec)

mysql> select * from tabel_dvd where hargasewa>10000;


+-------+------------+-------+-------------------+-----------+
| kddvd | judulfilm | genre | produksi

| hargasewa |

+-------+------------+-------+-------------------+-----------+
| D0003 | 2012

| Actio | Columbia Pictures |

25000 |

| D0004 | Laskar Pel | Drama | Miles Production |

15000 |

+-------+------------+-------+-------------------+-----------+
2 rows in set (0.00 sec)

mysql>exit

terus klik kanan CMDnya, pilih select all terus tekan CTRL + C di keyboard.
buka Notepadnya, tekan CTRL + V keyboard di Notepadnya. simpen notepadnya.

You might also like