其他
来试试这道 MySQL 面试题吧,比 Leecode 好玩多了~~~
mysql> show create table x\G
***********1.row*************
Table:x
Create Table: CREATE TABLE `x`(
`a` INT NOT NULL AUTO INCREMENT,
`b` VARCHAR(1),
PRIMARY KEY (`a`)) ENGINE=InnODB;
mysql> SELECT * FROM x;
+---+------+
| a | b |
+---+------+
| 0 | a |
| 2 | b |
+---+------+
mysql> ALTER TABLE x MODIFY COLUMN b VARCHAR(5);
mysql> show create table y\G
***********1.row*************
Table:y
Create Table: CREATE TABLE `y`(
`a` INT,
`b` VARCHAR(1),
PRIMARY KEY (`a`)) ENGINE=InnODB;
mysql> SELECT * FROM y;
+---+------+
| a | b |
+---+------+
| 0 | a |
| 2 | b |
+---+------+
mysql> ALTER TABLE y MODIFY COLUMN a INT AUTO_INCREMENT;
往期推荐