Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:UsersACER>cd c:xamppmysqlbin
c:xamppmysqlbin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 64
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> create database db_latihan_uts;
Query OK, 1 row affected (0.00 sec)
mysql> use db_latihan_uts;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table tb_user(kd_petugas char (5) not null primary key,
-> nama_petugas varchar (25),
-> jenis_kelamin varchar (20),
-> alamat_petugas varchar (50),
-> telepon text);
Query OK, 0 rows affected (0.08 sec)
mysql> desc pegawai;
ERROR 1146 (42S02): Table 'db_latihan_uts.pegawai' doesn't exist
mysql> desc tb_user;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| kd_petugas | char(5) | NO | PRI | NULL | |
| nama_petugas | varchar(25) | YES | | NULL | |
| jenis_kelamin | varchar(20) | YES | | NULL | |
| alamat_petugas | varchar(50) | YES | | NULL | |
| telepon | text | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mysql> insert into tb_user values ('1','aditya','laki-laki','yogyakarta','08121
34567');
Query OK, 1 row affected (0.00 sec)
mysql> select*from tb_user;
+------------+--------------+---------------+----------------+-------------+
| kd_petugas | nama_petugas | jenis_kelamin | alamat_petugas | telepon |
+------------+--------------+---------------+----------------+-------------+
| 1 | aditya | laki-laki | yogyakarta | 08121334567 |
+------------+--------------+---------------+----------------+-------------+
1 row in set (0.00 sec)
mysql>

CONTOH MEMBUAT TABEL XAMPP

  • 1.
    Microsoft Windows [Version6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:UsersACER>cd c:xamppmysqlbin c:xamppmysqlbin>mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 64 Server version: 5.0.67-community-nt MySQL Community Edition (GPL) Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql> create database db_latihan_uts; Query OK, 1 row affected (0.00 sec) mysql> use db_latihan_uts; Database changed mysql> show tables; Empty set (0.00 sec) mysql> create table tb_user(kd_petugas char (5) not null primary key, -> nama_petugas varchar (25), -> jenis_kelamin varchar (20), -> alamat_petugas varchar (50), -> telepon text); Query OK, 0 rows affected (0.08 sec) mysql> desc pegawai; ERROR 1146 (42S02): Table 'db_latihan_uts.pegawai' doesn't exist mysql> desc tb_user; +----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+-------------+------+-----+---------+-------+ | kd_petugas | char(5) | NO | PRI | NULL | | | nama_petugas | varchar(25) | YES | | NULL | | | jenis_kelamin | varchar(20) | YES | | NULL | | | alamat_petugas | varchar(50) | YES | | NULL | | | telepon | text | YES | | NULL | | +----------------+-------------+------+-----+---------+-------+ 5 rows in set (0.01 sec) mysql> insert into tb_user values ('1','aditya','laki-laki','yogyakarta','08121 34567'); Query OK, 1 row affected (0.00 sec) mysql> select*from tb_user; +------------+--------------+---------------+----------------+-------------+ | kd_petugas | nama_petugas | jenis_kelamin | alamat_petugas | telepon | +------------+--------------+---------------+----------------+-------------+ | 1 | aditya | laki-laki | yogyakarta | 08121334567 | +------------+--------------+---------------+----------------+-------------+ 1 row in set (0.00 sec) mysql>