praktikumku basis data
| mysql |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.03 sec)
mysql> create database pretest;
Query OK, 1 row affected (0.00 sec)
mysql> use pretest;
Database changed
mysql> create table siswa (nis char (8) not null primary key, nama varchar(30),
alamat varchar(35));
Query OK, 0 rows affected (0.06 sec)
mysql> create table mapel (kode_mapel char (8) not null primary key, nama_mapel
varchar(20), jadwal varchar(10));
Query OK, 0 rows affected (0.03 sec)
mysql> desc siswa;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| nis | char(8) | NO | PRI | NULL | |
| nama | varchar(30) | YES | | NULL | |
| alamat | varchar(35) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> desc mapel;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| kode_mapel | char(8) | NO | PRI | NULL | |
| nama_mapel | varchar(20) | YES | | NULL | |
| jadwal | varchar(10) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> insert into siswa values('10018121','Asri','Jakal KM 12');
Query OK, 1 row affected (0.00 sec)
mysql> insert into siswa values('10018109','Ine','Janturan'),('10018122','Isda',
'Yogyakarta'),('10018099','Party','Glagahsari'),('10018100','Chandra','Magelang'
),('10018111','Ita','Warungboto');
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into mapel values('11223301','Sistem Informasi','Senin'),('1122330
2','Basisdata','Selasa'),('11223303','Jarkomdat','Rabu');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select *from siswa;
+----------+---------+-------------+
| nis | nama | alamat |
+----------+---------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Yogyakarta |
| 10018099 | Party | Glagahsari |
| 10018100 | Chandra | Magelang |
| 10018111 | Ita | Warungboto |
+----------+---------+-------------+
6 rows in set (0.00 sec)
mysql> select *from mapel;
+------------+------------------+--------+
| kode_mapel | nama_mapel | jadwal |
+------------+------------------+--------+
| 11223301 | Sistem Informasi | Senin |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
+------------+------------------+--------+
3 rows in set (0.00 sec)
mysql> insert into mapel values('11223304','Strategi Algoritma','Kamis'),('11223
305','IMK','Kamis');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+--------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+--------+
| 11223301 | Sistem Informasi | Senin |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+--------+
5 rows in set (0.00 sec)
mysql> update siswa set alamat='Bantul' where alamat='Yogyakarta';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select *from siswa;
+----------+---------+-------------+
| nis | nama | alamat |
+----------+---------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Bantul |
| 10018099 | Party | Glagahsari |
| 10018100 | Chandra | Magelang |
| 10018111 | Ita | Warungboto |
+----------+---------+-------------+
6 rows in set (0.00 sec)
mysql> delete from siswa where alamat='Magelang';
Query OK, 1 row affected (0.00 sec)
mysql> select *from siswa;
+----------+-------+-------------+
| nis | nama | alamat |
+----------+-------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Bantul |
| 10018099 | Party | Glagahsari |
| 10018111 | Ita | Warungboto |
+----------+-------+-------------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Senin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where nama_mapel='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where nama_mapel='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| phpmyadmin |
| praktikumku |
| pretest |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> use praktikumku;
Database changed
mysql> select sum(nilai) from ambil;
+------------+
| sum(nilai) |
+------------+
| 510 |
+------------+
1 row in set (0.03 sec)
mysql> select count(*) from ambil;
+----------+
| count(*) |
+----------+
| 6 |
+----------+
1 row in set (0.00 sec)
mysql> select *from mahasiswa where alamat='Yogyakarta';
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
2 rows in set (0.02 sec)
mysql> select *from mahasiswa;
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018002 | Isna | P | Magelang | 101012 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
3 rows in set (0.00 sec)
mysql> select *from mahasiswa where alamat<> 'Yogyakarta';
+----------+------+----+----------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+----------+--------+
| 05018002 | Isna | P | Magelang | 101012 |
+----------+------+----+----------+--------+
1 row in set (0.00 sec)
mysql> select *from mahasiswa where alamat like '%Yogyakarta%';
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
2 rows in set (0.01 sec)
mysql> select *from mahasiswa where alamat like '%Yogya%';
pretest
| mysql |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.03 sec)
mysql> create database pretest;
Query OK, 1 row affected (0.00 sec)
mysql> use pretest;
Database changed
mysql> create table siswa (nis char (8) not null primary key, nama varchar(30),
alamat varchar(35));
Query OK, 0 rows affected (0.06 sec)
mysql> create table mapel (kode_mapel char (8) not null primary key, nama_mapel
varchar(20), jadwal varchar(10));
Query OK, 0 rows affected (0.03 sec)
mysql> desc siswa;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| nis | char(8) | NO | PRI | NULL | |
| nama | varchar(30) | YES | | NULL | |
| alamat | varchar(35) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> desc mapel;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| kode_mapel | char(8) | NO | PRI | NULL | |
| nama_mapel | varchar(20) | YES | | NULL | |
| jadwal | varchar(10) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> insert into siswa values('10018121','Asri','Jakal KM 12');
Query OK, 1 row affected (0.00 sec)
mysql> insert into siswa values('10018109','Ine','Janturan'),('10018122','Isda',
'Yogyakarta'),('10018099','Party','Glagahsari'),('10018100','Chandra','Magelang'
),('10018111','Ita','Warungboto');
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into mapel values('11223301','Sistem Informasi','Senin'),('1122330
2','Basisdata','Selasa'),('11223303','Jarkomdat','Rabu');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select *from siswa;
+----------+---------+-------------+
| nis | nama | alamat |
+----------+---------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Yogyakarta |
| 10018099 | Party | Glagahsari |
| 10018100 | Chandra | Magelang |
| 10018111 | Ita | Warungboto |
+----------+---------+-------------+
6 rows in set (0.00 sec)
mysql> select *from mapel;
+------------+------------------+--------+
| kode_mapel | nama_mapel | jadwal |
+------------+------------------+--------+
| 11223301 | Sistem Informasi | Senin |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
+------------+------------------+--------+
3 rows in set (0.00 sec)
mysql> insert into mapel values('11223304','Strategi Algoritma','Kamis'),('11223
305','IMK','Kamis');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+--------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+--------+
| 11223301 | Sistem Informasi | Senin |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+--------+
5 rows in set (0.00 sec)
mysql> update siswa set alamat='Bantul' where alamat='Yogyakarta';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select *from siswa;
+----------+---------+-------------+
| nis | nama | alamat |
+----------+---------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Bantul |
| 10018099 | Party | Glagahsari |
| 10018100 | Chandra | Magelang |
| 10018111 | Ita | Warungboto |
+----------+---------+-------------+
6 rows in set (0.00 sec)
mysql> delete from siswa where alamat='Magelang';
Query OK, 1 row affected (0.00 sec)
mysql> select *from siswa;
+----------+-------+-------------+
| nis | nama | alamat |
+----------+-------+-------------+
| 10018121 | Asri | Jakal KM 12 |
| 10018109 | Ine | Janturan |
| 10018122 | Isda | Bantul |
| 10018099 | Party | Glagahsari |
| 10018111 | Ita | Warungboto |
+----------+-------+-------------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Senin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where nama_mapel='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where nama_mapel='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> update mapel set jadwal='5-5-2012' where jadwal='Basis Data';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select *from mapel;
+------------+--------------------+----------+
| kode_mapel | nama_mapel | jadwal |
+------------+--------------------+----------+
| 11223301 | Sistem Informasi | 5-5-2012 |
| 11223302 | Basisdata | Selasa |
| 11223303 | Jarkomdat | Rabu |
| 11223304 | Strategi Algoritma | Kamis |
| 11223305 | IMK | Kamis |
+------------+--------------------+----------+
5 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| phpmyadmin |
| praktikumku |
| pretest |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> use praktikumku;
Database changed
mysql> select sum(nilai) from ambil;
+------------+
| sum(nilai) |
+------------+
| 510 |
+------------+
1 row in set (0.03 sec)
mysql> select count(*) from abil;
ERROR 1146 (42S02): Table 'praktikumku.abil' doesn't exist
mysql> select count(*) from ambil;
+----------+
| count(*) |
+----------+
| 6 |
+----------+
1 row in set (0.00 sec)
mysql> select *from mahasiswa where alamat='Yogyakarta';
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
2 rows in set (0.02 sec)
mysql> select *from mahasiswa;
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018002 | Isna | P | Magelang | 101012 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
3 rows in set (0.00 sec)
mysql> select *from mahasiswa where alamat<> 'Yogyakarta';
+----------+------+----+----------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+----------+--------+
| 05018002 | Isna | P | Magelang | 101012 |
+----------+------+----+----------+--------+
1 row in set (0.00 sec)
mysql> select *from mahasiswa where alamat like '%Yogyakarta%';
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
2 rows in set (0.01 sec)
mysql> select *from mahasiswa where alamat like '%Yogya%';
postes:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\BASDAT>cd..
C:\Documents and Settings>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 15
Server version: 5.1.41 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| phpmyadmin |
| praktikumku |
| pretest |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> use praktikumku;
Database changed
mysql> select sum(nilai) from ambil;
+------------+
| sum(nilai) |
+------------+
| 510 |
+------------+
1 row in set (0.03 sec)
mysql> select count(*)rfom ambil;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'ambil
' at line 1
mysql> select count(*)from ambil;
+----------+
| count(*) |
+----------+
| 6 |
+----------+
1 row in set (0.00 sec)
mysql> select *from mahasiswa where alamat='yogyakarta';
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
2 rows in set (0.01 sec)
mysql> select *from mahasiswa;
+----------+------+----+------------+--------+
| nim | nama | jk | alamat | nip |
+----------+------+----+------------+--------+
| 05018001 | Andi | L | Yogyakarta | 101011 |
| 05018002 | Isna | P | Magelang | 101012 |
| 05018003 | Dion | L | Yogyakarta | 101011 |
+----------+------+----+------------+--------+
3 rows in set (0.00 sec)
mysql> select max(nilai)from ambil where kd_mk='T0000002';
+------------+
| max(nilai) |
+------------+
| 85 |
+------------+
1 row in set (0.03 sec)
mysql> select count(*)from ambil where kd_mk='T0000002';
+----------+
| count(*) |
+----------+
| 2 |
+----------+
1 row in set (0.00 sec)
mysql> select sum(nilai)from ambil where kd_mk='T0000002';
+------------+
| sum(nilai) |
+------------+
| 150 |
+------------+
1 row in set (0.00 sec)
mysql> select avg(nilai)from ambil where kd_mk='T0000002';
+------------+
| avg(nilai) |
+------------+
| 75.0000 |
+------------+
1 row in set (0.00 sec)
mysql>