This is my first time using mysql to make database, let me see for my first work :
first install mysql on your ubuntu, you can look the way to istall it on my old posting, click here. If you have finish, lets makes database
root@poliwangi-desktop:/home/poliwangi# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql> create database AKADEMIK;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| mysql |
+--------------------+
3 rows in set (0.00 sec)
mysql> create database akademic;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| akademic |
| mysql |
+--------------------+
4 rows in set (0.00 sec)
mysql> use akademic
Database changed
mysql> create table MHS (
-> NRP int(15) not null primary key,
-> NAMA char(25) not null,
-> ALAMAT char(60) not null)
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> desc MHS;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| NRP | int(15) | NO | PRI | NULL | |
| NAMA | char(25) | NO | | NULL | |
| ALAMAT | char(60) | NO | | NULL | |
+--------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> show tables;
+--------------------+
| Tables_in_akademic |
+--------------------+
| MHS |
+--------------------+
1 row in set (0.00 sec)
mysql> create table MKUL (
-> KDMK char(5) not null primary key,
-> MTKULIAH char(10) not null,
-> SKS int(20) not null )
-> ;
Query OK, 0 rows affected (0.01 sec)
mysql> desc MKUL;
+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| KDMK | char(5) | NO | PRI | NULL | |
| MTKULIAH | char(10) | NO | | NULL | |
| SKS | int(20) | NO | | NULL | |
+----------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> use akademic;
Database changed
mysql> create table NILAI (
-> NRP int(15) not null,
-> KDMK char(5) not null,
-> MID int(7) not null,
-> FINAL int(7) not null )
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> desc NILAI;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| NRP | int(15) | NO | | NULL | |
| KDMK | char(5) | NO | | NULL | |
| MID | int(7) | NO | | NULL | |
| FINAL | int(7) | NO | | NULL | |
+-------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| akademic |
| akademik |
| mysql |
+--------------------+
5 rows in set (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('01','Adin','Surabaya');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('02','Adi','Surabaya');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('03','Budi','Malang');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('04','Edi','Jember');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('05','Caca','Lumajang');
Query OK, 1 row affected (0.00 sec)
mysql> select*from MHS
-> ;
+-----+------+----------+
| NRP | NAMA | ALAMAT |
+-----+------+----------+
| 1 | Adin | Surabaya |
| 2 | Adi | Surabaya |
| 3 | Budi | Malang |
| 4 | Edi | Jember |
| 5 | Caca | Lumajang |
+-----+------+----------+
5 rows in set (0.00 sec)
mysql> show tables;
+--------------------+
| Tables_in_akademic |
+--------------------+
| MHS |
| MKUL |
| NILAI |
+--------------------+
3 rows in set (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A1','Basis data','2');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A2','Design Web','3');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A3','Pemrograman','2');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A4','Sistem Digital','3');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A5','Matematika','3');
Query OK, 1 row affected (0.00 sec)
mysql> select * from MKUL;
+------+------------+-----+
| KDMK | MTKULIAH | SKS |
+------+------------+-----+
| A1 | Basis data | 2 |
| A2 | Design Web | 3 |
| A3 | Pemrograma | 2 |
| A4 | Sistem Dig | 3 |
| A5 | Matematika | 3 |
+------+------------+-----+
5 rows in set (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('1','A3','70');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from NILAI
-> ;
+-----+------+-----+-------+
| NRP | KDMK | MID | FINAL |
+-----+------+-----+-------+
| 1 | A3 | 70 | 0 |
+-----+------+-----+-------+
1 row in set (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('5','A3','80');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('2','A3','50');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('4','A3','60');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from NILAI
-> ;
+-----+------+-----+-------+
| NRP | KDMK | MID | FINAL |
+-----+------+-----+-------+
| 1 | A3 | 70 | 0 |
| 5 | A3 | 80 | 0 |
| 2 | A3 | 50 | 0 |
| 4 | A3 | 60 | 0 |
+-----+------+-----+-------+
4 rows in set (0.00 sec)
mysql> select sum(MID) from NILAI;
+----------+
| sum(MID) |
+----------+
| 260 |
+----------+
1 row in set (0.00 sec)
mysql> select avg(MID) from NILAI;
+----------+
| avg(MID) |
+----------+
| 65.0000 |
+----------+
1 row in set (0.00 sec)
mysql> select max(MID) from NILAI;
+----------+
| max(MID) |
+----------+
| 80 |
+----------+
1 row in set (0.00 sec)
mysql> select min(MID) from NILAI;
+----------+
| min(MID) |
+----------+
| 50 |
+----------+
1 row in set (0.00 sec)
mysql> select count(MID) from NILAI;
+------------+
| count(MID) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql> Quit
first install mysql on your ubuntu, you can look the way to istall it on my old posting, click here. If you have finish, lets makes database
root@poliwangi-desktop:/home/poliwangi# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql> create database AKADEMIK;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| mysql |
+--------------------+
3 rows in set (0.00 sec)
mysql> create database akademic;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| akademic |
| mysql |
+--------------------+
4 rows in set (0.00 sec)
mysql> use akademic
Database changed
mysql> create table MHS (
-> NRP int(15) not null primary key,
-> NAMA char(25) not null,
-> ALAMAT char(60) not null)
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> desc MHS;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| NRP | int(15) | NO | PRI | NULL | |
| NAMA | char(25) | NO | | NULL | |
| ALAMAT | char(60) | NO | | NULL | |
+--------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> show tables;
+--------------------+
| Tables_in_akademic |
+--------------------+
| MHS |
+--------------------+
1 row in set (0.00 sec)
mysql> create table MKUL (
-> KDMK char(5) not null primary key,
-> MTKULIAH char(10) not null,
-> SKS int(20) not null )
-> ;
Query OK, 0 rows affected (0.01 sec)
mysql> desc MKUL;
+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| KDMK | char(5) | NO | PRI | NULL | |
| MTKULIAH | char(10) | NO | | NULL | |
| SKS | int(20) | NO | | NULL | |
+----------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> use akademic;
Database changed
mysql> create table NILAI (
-> NRP int(15) not null,
-> KDMK char(5) not null,
-> MID int(7) not null,
-> FINAL int(7) not null )
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> desc NILAI;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| NRP | int(15) | NO | | NULL | |
| KDMK | char(5) | NO | | NULL | |
| MID | int(7) | NO | | NULL | |
| FINAL | int(7) | NO | | NULL | |
+-------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AKADEMIK |
| akademic |
| akademik |
| mysql |
+--------------------+
5 rows in set (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('01','Adin','Surabaya');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('02','Adi','Surabaya');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('03','Budi','Malang');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('04','Edi','Jember');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MHS
-> (NRP,NAMA,ALAMAT) values
-> ('05','Caca','Lumajang');
Query OK, 1 row affected (0.00 sec)
mysql> select*from MHS
-> ;
+-----+------+----------+
| NRP | NAMA | ALAMAT |
+-----+------+----------+
| 1 | Adin | Surabaya |
| 2 | Adi | Surabaya |
| 3 | Budi | Malang |
| 4 | Edi | Jember |
| 5 | Caca | Lumajang |
+-----+------+----------+
5 rows in set (0.00 sec)
mysql> show tables;
+--------------------+
| Tables_in_akademic |
+--------------------+
| MHS |
| MKUL |
| NILAI |
+--------------------+
3 rows in set (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A1','Basis data','2');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A2','Design Web','3');
Query OK, 1 row affected (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A3','Pemrograman','2');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A4','Sistem Digital','3');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into MKUL (KDMK,MTKULIAH,SKS) values ('A5','Matematika','3');
Query OK, 1 row affected (0.00 sec)
mysql> select * from MKUL;
+------+------------+-----+
| KDMK | MTKULIAH | SKS |
+------+------------+-----+
| A1 | Basis data | 2 |
| A2 | Design Web | 3 |
| A3 | Pemrograma | 2 |
| A4 | Sistem Dig | 3 |
| A5 | Matematika | 3 |
+------+------------+-----+
5 rows in set (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('1','A3','70');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from NILAI
-> ;
+-----+------+-----+-------+
| NRP | KDMK | MID | FINAL |
+-----+------+-----+-------+
| 1 | A3 | 70 | 0 |
+-----+------+-----+-------+
1 row in set (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('5','A3','80');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('2','A3','50');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> insert into NILAI (NRP,KDMK,MID) values ('4','A3','60');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from NILAI
-> ;
+-----+------+-----+-------+
| NRP | KDMK | MID | FINAL |
+-----+------+-----+-------+
| 1 | A3 | 70 | 0 |
| 5 | A3 | 80 | 0 |
| 2 | A3 | 50 | 0 |
| 4 | A3 | 60 | 0 |
+-----+------+-----+-------+
4 rows in set (0.00 sec)
mysql> select sum(MID) from NILAI;
+----------+
| sum(MID) |
+----------+
| 260 |
+----------+
1 row in set (0.00 sec)
mysql> select avg(MID) from NILAI;
+----------+
| avg(MID) |
+----------+
| 65.0000 |
+----------+
1 row in set (0.00 sec)
mysql> select max(MID) from NILAI;
+----------+
| max(MID) |
+----------+
| 80 |
+----------+
1 row in set (0.00 sec)
mysql> select min(MID) from NILAI;
+----------+
| min(MID) |
+----------+
| 50 |
+----------+
1 row in set (0.00 sec)
mysql> select count(MID) from NILAI;
+------------+
| count(MID) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql> Quit
Komentar
Posting Komentar
Ramaikan Blog Ini Dengan Komentar-Komentar Anda
Bebas, Sopan, Ataktif, Kritik Juga Boleh