1.
Cd c:\xampp\mysql\bin
Mysql –u root –p
2.
Create table mahaiswa ….
3.
Insert into nama table values ()
4.
Select * from …
5.
Alter table namaa table modify ….
6.
Select from where
7.
Ubah data
Update nama table set….
Update mahasiswa set alamat =’yogyakarta’;
8.
Hapus data
Delete from tnama table where
9.
Menampilkan kode buku yang mengandung kode buku
selain 123
Select * from buku where kd_buku < > ‘123’
10.
Menampilkan data buku yg mengandung judul basis
data
Select * from buku where judul like ‘%basis
data%’
11.
Menampilkan data buku yg mengandung judul basis
data dan tahun terbit 2012
Select * from buku where judul like ‘%basis
data%’ and tahun terbit = ‘2012’
12.
Select count (*) from ambil
13.
Alter table mahasiswa drop
14.
Cari nama mhs yg diawali R
15.
Select nim, nama_mhs from mhs where nama_mhs
like ‘R%’
16.
Select avg(nilai)from
17.
Nama dosen yang mengajar kuliah dengan kodekul
it100
Select d.nama_dosen from dosen as d left
join mengajar as m on nip = m.nip where kode_kul =’it100’
18.
Select max(nilai)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\BASDAT>cd c:\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 1
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 |
| test |
+--------------------+
5 rows in set (0.06 sec)
mysql> create database irma;
Query OK, 1 row affected (0.00 sec)
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| mysql |
| phpmyadmin |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> use irma;
Database changed
mysql> create table mhs (nim char(8) primary key, nama_mhs varchar(25));
Query OK, 0 rows affected (0.06 sec)
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> alter table mhs sdd (alamat varchar(30));
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 'sdd (
alamat varchar(30))' at line 1
mysql> alter table mhs add (alamat varchar(30));
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table mhs add telp varchar(13) after nama_mhs;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| telp | varchar(13) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> alter table mhs drop telp;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> alter table mhs modify alamat varchar(100);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(100) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table mhs rename alamat to alamat_mhs;
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 'to al
amat_mhs' at line 1
mysql> alter table mhs rename to mahasiswa;
Query OK, 0 rows affected (0.00 sec)
mysql> desc mhs;
ERROR 1146 (42S02): Table 'irma.mhs' doesn't exist
mysql> desc mahasiswa_UAD;
ERROR 1146 (42S02): Table 'irma.mahasiswa_uad' doesn't exist
mysql> drop table mahasiswa_UAD;
ERROR 1051 (42S02): Unknown table 'mahasiswa_uad'
mysql> create database Kuliah;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| kuliah |
| mysql |
| phpmyadmin |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> use kuliah;
Database changed
mysql> create table kuliah (siswa char(50) matkul varchar (20));
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 'matku
l varchar (20))' at line 1
mysql> create table kuliah (siswa char(50), matkul char(20));
Query OK, 0 rows affected (0.05 sec)
mysql> desc kuliah;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| siswa | char(50) | YES | | NULL | |
| matkul | char(20) | YES | | NULL | |
+--------+----------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> create database siswa;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| kuliah |
| mysql |
| phpmyadmin |
| siswa |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> use siswa;
Database changed
mysql> creste table siswa (nim char(8) primary key, nama_siswa varchar(25));
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 'crest
e table siswa (nim char(8) primary key, nama_siswa varchar(25))' at line 1
mysql> create table siswa
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\BASDAT>cd c:\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 1
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 |
| test |
+--------------------+
5 rows in set (0.06 sec)
mysql> create database irma;
Query OK, 1 row affected (0.00 sec)
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| mysql |
| phpmyadmin |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> use irma;
Database changed
mysql> create table mhs (nim char(8) primary key, nama_mhs varchar(25));
Query OK, 0 rows affected (0.06 sec)
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> alter table mhs sdd (alamat varchar(30));
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 'sdd (
alamat varchar(30))' at line 1
mysql> alter table mhs add (alamat varchar(30));
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table mhs add telp varchar(13) after nama_mhs;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| telp | varchar(13) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> alter table mhs drop telp;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> alter table mhs modify alamat varchar(100);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc mhs;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| nim | char(8) | NO | PRI | NULL | |
| nama_mhs | varchar(25) | YES | | NULL | |
| alamat | varchar(100) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table mhs rename alamat to alamat_mhs;
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 'to al
amat_mhs' at line 1
mysql> alter table mhs rename to mahasiswa;
Query OK, 0 rows affected (0.00 sec)
mysql> desc mhs;
ERROR 1146 (42S02): Table 'irma.mhs' doesn't exist
mysql> desc mahasiswa_UAD;
ERROR 1146 (42S02): Table 'irma.mahasiswa_uad' doesn't exist
mysql> drop table mahasiswa_UAD;
ERROR 1051 (42S02): Unknown table 'mahasiswa_uad'
mysql> create database Kuliah;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| kuliah |
| mysql |
| phpmyadmin |
| test |
+--------------------+
7 rows in set (0.00 sec)
mysql> use kuliah;
Database changed
mysql> create table kuliah (siswa char(50) matkul varchar (20));
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 'matku
l varchar (20))' at line 1
mysql> create table kuliah (siswa char(50), matkul char(20));
Query OK, 0 rows affected (0.05 sec)
mysql> desc kuliah;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| siswa | char(50) | YES | | NULL | |
| matkul | char(20) | YES | | NULL | |
+--------+----------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> create database siswa;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| irma |
| kuliah |
| mysql |
| phpmyadmin |
| siswa |
| test |
+--------------------+
8 rows in set (0.00 sec)
mysql> use siswa;
Database changed
mysql> creste table siswa (nim char(8) primary key, nama_siswa varchar(25));
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 'crest
e table siswa (nim char(8) primary key, nama_siswa varchar(25))' at line 1
mysql> create table siswa