Anda di halaman 1dari 3

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| performance_schema |
| phpmyadmin |
| rmh_sakit |
| rumah_sakit |
| test |
| webauth |
+--------------------+
9 rows in set (0.00 sec)

mysql> create databse db_dokter;


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 'databse
db_dokter' at line 1
mysql> create db_petugas;
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
'db_petugas' at line 1
mysql> create database db_rumah_sakit;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| db_rumah_sakit |
| mysql |
| performance_schema |
| phpmyadmin |
| rmh_sakit |
| rumah_sakit |
| test |
| webauth |
+--------------------+
10 rows in set (0.00 sec)

mysql> create table tb_petugas(


-> idpetugas varchar(8) primary key,
-> namapetugas varchar(25) not null,
-> alamatpetugas text not null,
-> shippetugas text not null,
-> nohp petugas varchar(12) not null);
ERROR 1046 (3D000): No database selected
mysql> use db_rumah_sakit;
Database changed
mysql> create table tb_petugasrs(
-> idpetugas varchar(8) primary key,
-> namapetugas varchar(25) not null,
-> alamatpetugas text not null,
-> shippetugas varchar(10) not null,
-> nohp petugas varchar(12) not null);
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 'petugas
varchar(12) not null)' at line 6
mysql> use db_rumah_sakit;
Database changed
mysql> create table tb_dokter(
-> kode_dokter varchar(10) primary key.
-> nama_dokter varchar(30) not null,
-> alamat_dokter varchar(30) not null,
-> spesialis varchar(30)not null>;
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 '.
nama_dokter varchar(30) not null,
alamat_dokter varchar(30) not null,
spesiali' at line 2
mysql> use db_rumah_sakit;
Database changed
mysql> create table dokter (
-> kode_dokter varchar(10) primary key,
-> nama_dokter varchar(30),
-> alamat_dokter varchar(30),
-> spesialis varchar(30));
Query OK, 0 rows affected (0.67 sec)

mysql> desc dokter;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_dokter | varchar(10) | NO | PRI | NULL | |
| nama_dokter | varchar(30) | YES | | NULL | |
| alamat_dokter | varchar(30) | YES | | NULL | |
| spesialis | varchar(30) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.03 sec)

mysql> alter table dokter add nohp varchar(12) not null after kode_dokter;
Query OK, 0 rows affected (0.89 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc dokter;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_dokter | varchar(10) | NO | PRI | NULL | |
| nohp | varchar(12) | NO | | NULL | |
| nama_dokter | varchar(30) | YES | | NULL | |
| alamat_dokter | varchar(30) | YES | | NULL | |
| spesialis | varchar(30) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
5 rows in set (0.03 sec)

mysql> alter table dokter drop spesialis;


Query OK, 0 rows affected (0.53 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc dokter;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_dokter | varchar(10) | NO | PRI | NULL | |
| nohp | varchar(12) | NO | | NULL | |
| nama_dokter | varchar(30) | YES | | NULL | |
| alamat_dokter | varchar(30) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.03 sec)

mysql> alter table dokter rename to tbl_dokter;


Query OK, 0 rows affected (0.47 sec)

mysql> desc tbl_dokter;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_dokter | varchar(10) | NO | PRI | NULL | |
| nohp | varchar(12) | NO | | NULL | |
| nama_dokter | varchar(30) | YES | | NULL | |
| alamat_dokter | varchar(30) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.03 sec)

mysql> alter table tbl_dokter change nohp nomor_hp varchar(12) not null;
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc tbl_dokter;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| kode_dokter | varchar(10) | NO | PRI | NULL | |
| nomor_hp | varchar(12) | NO | | NULL | |
| nama_dokter | varchar(30) | YES | | NULL | |
| alamat_dokter | varchar(30) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)