Sunteți pe pagina 1din 3

Microsoft Windows XP [Version 5.1.

2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Lab1a>cd c:\appserv\mysql\bin
C:\AppServ\MySQL\bin>mysql -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.27-community-nt-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use latihan1;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_latihan1 |
+--------------------+
| tabel1 |
| tabel2 |
+--------------------+
2 rows in set (0.02 sec)
mysql> ALTER TABLE latihan1 ADD huruf varchar(1);
ERROR 1146 (42S02): Table 'latihan1.latihan1' doesn't exist
mysql> ALTER TABLE tabel1 ADD huruf varchar(1);
Query OK, 2 rows affected (0.05 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
| huruf | varchar(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> ALTER TABLE tabel1 MODIFY COLUMN huruf varchar(3);
Query OK, 2 rows affected (0.02 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
| huruf | varchar(3) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> ALTER TABLE tabel1 CHANGE COLUMN huruf data varchar(1);
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
| data | varchar(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> ALTER TABLE tabel1 DROP COLUMN data;
Query OK, 2 rows affected (0.02 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> create tabel3;
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 'tabel
3' at line 1
mysql> create TABLE tabel3;
ERROR 1113 (42000): A table must have at least 1 column
mysql> create TABLE tabel3(3);
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 '3)' a
t line 1
mysql> create TABLE tabel3
-> (
-> NIM varchar
-> (12) PRIMARY KEY,
-> Nama varchar(10),
-> Nilai int(8)
-> );
Query OK, 0 rows affected (0.05 sec)
mysql> desc tabel3;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| NIM | varchar(12) | NO | PRI | | |
| Nama | varchar(10) | YES | | NULL | |
| Nilai | int(8) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql>
mysql> ALTER TABLE tabel1 ADD CONSTRAINT chayo PRIMARY KEY(no);
Query OK, 2 rows affected (0.06 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | PRI | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> ALTER TABLE tabel1 DROP CONSTRAINT chayo;
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 'CONST
RAINT chayo' at line 1
mysql> ALTER TABLE tabel1 DROP PRIMARY KEY;
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> desc tabel1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| no | tinyint(4) | NO | | | |
| nama | varchar(30) | NO | | | |
| nilai | tinyint(4) | NO | | | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql>

S-ar putea să vă placă și