Вы находитесь на странице: 1из 3

| information_schema |

| cdcol
|
| coba
|
| db_berita
|
| kampus
|
| mysql
|
| phpmyadmin
|
| test
|
| toko
|
| upload
|
+--------------------+
10 rows in set (0.01 sec)
mysql> use toko;
Database changed
mysql> create table barang(kode char(4) primary key, nabar varchar(30), harga in
t(5));
Query OK, 0 rows affected (0.39 sec)
mysql> desc barang;
+-------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| kode | char(4)
| NO | PRI | NULL
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| harga | int(5)
| YES |
| NULL
|
|
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> desc brg
-> ;
ERROR 1146 (42S02): Table 'toko.brg' doesn't exist
mysql> desc barang;
+-------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| kode | char(4)
| NO | PRI | NULL
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| harga | int(5)
| YES |
| NULL
|
|
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_toko |
+----------------+
| barang
|
+----------------+
1 row in set (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_toko |
+----------------+
| barang
|
+----------------+
1 row in set (0.00 sec)
mysql> desc barang;
+-------+-------------+------+-----+---------+-------+

| Field | Type
| Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| kode | char(4)
| NO | PRI | NULL
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| harga | int(5)
| YES |
| NULL
|
|
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table barang change kode kobar;
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 '' at
line 1
mysql> alter table barang change kode kobar char(4);
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc barang;
+-------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| kobar | char(4)
| NO | PRI |
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| harga | int(5)
| YES |
| NULL
|
|
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> alter table barang add satuan varchar(20) after harga;
Query OK, 0 rows affected (0.39 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc barang;
+--------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| kobar | char(4)
| NO | PRI |
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| harga | int(5)
| YES |
| NULL
|
|
| satuan | varchar(20) | YES |
| NULL
|
|
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
mysql> alter table barang drop harga;
Query OK, 0 rows affected (0.38 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc barang;
+--------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| kobar | char(4)
| NO | PRI |
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| satuan | varchar(20) | YES |
| NULL
|
|
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> rename table barang to brg;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables
-> ;

+----------------+
| Tables_in_toko |
+----------------+
| brg
|
+----------------+
1 row in set (0.00 sec)
mysql> desc brg;
+--------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| kobar | char(4)
| NO | PRI |
|
|
| nabar | varchar(30) | YES |
| NULL
|
|
| satuan | varchar(20) | YES |
| NULL
|
|
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> desc mahasiswa;
ERROR 1146 (42S02): Table 'toko.mahasiswa' doesn't exist
mysql> desc mhs;
ERROR 1146 (42S02): Table 'toko.mhs' doesn't exist
mysql> use kampus;
Database changed
mysql> desc mhs;
+--------+-------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| nim
| varchar(8) | NO | PRI |
|
|
| nm_mhs | varchar(30) | YES |
| NULL
|
|
| alamat | varchar(30) | YES |
| NULL
|
|
| jekel | varchar(30) | YES |
| NULL
|
|
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
mysql> insert into values("MHS01","slamet","tangerang","pria");
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 'value
s("MHS01","slamet","tangerang","pria")' at line 1
mysql> insert into mhs values("MHS01","slamet","tangerang","pria");
Query OK, 1 row affected (0.00 sec)

Вам также может понравиться