Databaserej

5
Nama :Ahmad Riyan Dayani NPM : 12110796 Kelas :TI-P 1217 Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Users\riyan_dayani>cd\ C:\>cd\xampp\mysql\bin C:\xampp\mysql\bin>mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.16 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cdcol | | dbmovie | | dbpenjualan | | mysql | | performance_schema | | phpmyadmin | | test | | webauth | +--------------------+

description

dhdghjdfhfdshsdf

Transcript of Databaserej

Page 1: Databaserej

Nama :Ahmad Riyan Dayani

NPM : 12110796

Kelas :TI-P 1217

Microsoft Windows [Version 6.2.9200]

(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\riyan_dayani>cd\

C:\>cd\xampp\mysql\bin

C:\xampp\mysql\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| cdcol |

| dbmovie |

| dbpenjualan |

| mysql |

| performance_schema |

| phpmyadmin |

| test |

| webauth |

+--------------------+

9 rows in set (0.00 sec)

mysql> create database riyan;

Query OK, 1 row affected (0.03 sec)

Page 2: Databaserej

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| cdcol |

| dbmovie |

| dbpenjualan |

| mysql |

| performance_schema |

| phpmyadmin |

| riyan |

| test |

| webauth |

+--------------------+

10 rows in set (0.00 sec)

mysql> use riyan;

Database changed

mysql> create table bioskop(

-> kdfilm varchar(10),

-> nmflim varchar(30));

Query OK, 0 rows affected (0.34 sec)

mysql> desc bioskop;

+--------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| kdfilm | varchar(10) | YES | | NULL | |

| nmflim | varchar(30) | YES | | NULL | |

+--------+-------------+------+-----+---------+-------+

2 rows in set (0.27 sec)

mysql> insert into bioskop(kdfilm,nmflim)values

-> ('s-01*01','rambo'),

-> ('l/02*02','OVJ'),

Page 3: Databaserej

-> ('h/03*03','fs6');

Query OK, 3 rows affected (0.00 sec)

Records: 3 Duplicates: 0 Warnings: 0

mysql> desc bioskop;

+--------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| kdfilm | varchar(10) | YES | | NULL | |

| nmflim | varchar(30) | YES | | NULL | |

+--------+-------------+------+-----+---------+-------+

2 rows in set (0.02 sec)

mysql> alter table bioskop

-> add jenis varchar(15),

-> add kdbangku varchar(6),

-> add nmsaya varchar(25);

Query OK, 3 rows affected (0.03 sec)

Records: 3 Duplicates: 0 Warnings: 0

mysql> desc bioskop;

+----------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| kdfilm | varchar(10) | YES | | NULL | |

| nmflim | varchar(30) | YES | | NULL | |

| jenis | varchar(15) | YES | | NULL | |

| kdbangku | varchar(6) | YES | | NULL | |

| nmsaya | varchar(25) | YES | | NULL | |

+----------+-------------+------+-----+---------+-------+

5 rows in set (0.31 sec)

mysql> select * from bioskop;

+---------+--------+-------+----------+--------+

| kdfilm | nmflim | jenis | kdbangku | nmsaya |

+---------+--------+-------+----------+--------+

| s-01*01 | rambo | NULL | NULL | NULL |

Page 4: Databaserej

| l/02*02 | OVJ | NULL | NULL | NULL |

| h/03*03 | fs6 | NULL | NULL | NULL |

+---------+--------+-------+----------+--------+

3 rows in set (0.00 sec)

mysql> update bioskop set

-> jenis=case

-> when left(kdfilm,1)='s' then 'sinetron'

-> when left(kdfilm,1)='l' then 'laga'

-> when left(kdfilm,1)='h' then 'holy'

-> end,

-> kdbangku=case

-> when right(kdfilm,2)='01' then 'bangku01'

-> when right(kdfilm,2)='02' then 'bangku02'

-> when right(kdfilm,2)='03' then 'bangku03'

-> end,

-> nmsaya=case

-> when mid(kdfilm,5,1)='*' then 'ahmad'

-> when mid(kdfilm,5,1)='*' then 'riyan'

-> when mid(kdfilm,5,1)='*' then 'dayani'

-> end;

Query OK, 3 rows affected, 3 warnings (0.05 sec)

Rows matched: 3 Changed: 3 Warnings: 3

mysql> select * from bioskop;

+---------+--------+----------+----------+--------+

| kdfilm | nmflim | jenis | kdbangku | nmsaya |

+---------+--------+----------+----------+--------+

| s-01*01 | rambo | sinetron | bangku | ahmad |

| l/02*02 | OVJ | laga | bangku | ahmad |

| h/03*03 | fs6 | holy | bangku | ahmad |

+---------+--------+----------+----------+--------+

3 rows in set (0.00 sec)

mysql>