Microsoft Windows XP [版本 5.1.2600] (C) 版权所有 1985-2001 Microsoft Corp.
C:/Documents and Settings/Administrator>mysql -uroot -proot Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 4 Server version: 5.1.41-community MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.02 sec)
mysql> desc emp; +---------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------+------+-----+---------+-------+ | ename | varchar(30) | NO | PRI | | | | hirdate | date | YES | | NULL | | | sal | decimal(10,2) | YES | | NULL | | | deptno | int(2) | YES | | NULL | | | agenum | int(4) | YES | | NULL | | +---------+---------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)
mysql> alter table emp drop agenum; Query OK, 0 rows affected (0.17 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> desc emp; +---------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------+------+-----+---------+-------+ | ename | varchar(30) | NO | PRI | | | | hirdate | date | YES | | NULL | | | sal | decimal(10,2) | YES | | NULL | | | deptno | int(2) | YES | | NULL | | +---------+---------------+------+-----+---------+-------+ 4 rows in set (0.00 sec)
mysql> alter table emp add column birth date after ename; Query OK, 0 rows affected (0.16 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> desc emp; +---------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------+------+-----+---------+-------+ | ename | varchar(30) | NO | PRI | | | | birth | date | YES | | NULL | | | hirdate | date | YES | | NULL | | | sal | decimal(10,2) | YES | | NULL | | | deptno | int(2) | YES | | NULL | | +---------+---------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)
mysql> alter table emp modify sal first; 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 'first ' at line 1 mysql> alter table emp modify sal decimal(10,2) first; Query OK, 0 rows affected (0.16 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> desc emp; +---------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------+------+-----+---------+-------+ | sal | decimal(10,2) | YES | | NULL | | | ename | varchar(30) | NO | PRI | | | | birth | date | YES | | NULL | | | hirdate | date | YES | | NULL | | | deptno | int(2) | YES | | NULL | | +---------+---------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)