增加枚举类型

MySql 码拜 8年前 (2016-02-19) 1293次浏览
讨教在表建好以后,想增加枚举类型,该怎么操作
解决方案

5

直接 :
alter table
add 列名 enum(….)

15

直接加就行了:
mysql> create table tx(t enum(“1″,”2”));
Query OK, 0 rows affected (0.63 sec)
mysql> insert into tx values(“1”);
Query OK, 1 row affected (0.09 sec)
mysql> insert into tx values(“2”);
Query OK, 1 row affected (0.06 sec)
mysql> select * from tx;
+–+
| t    |
+–+
| 1    |
| 2    |
+–+
2 rows in set (0.01 sec)
mysql> alter table tx
-> modify column t enum(“1″,”2″,”3”);
Query OK, 0 rows affected (0.15 sec)
Records: 0  Duplicates: 0  Warnings: 0
mysql> show create table tx;
+–+–+
| Table | Create Table                                                                                  |
+–+–+
| tx    | CREATE TABLE `tx` (
`t` enum(“1″,”2″,”3”) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+–+–+
1 row in set (0.01 sec)
mysql> select * from tx;
+–+
| t    |
+–+
| 1    |
| 2    |
+–+
2 rows in set (0.01 sec)
mysql> insert into tx values(“3”);
Query OK, 1 row affected (0.14 sec)
mysql> select * from tx;
+–+
| t    |
+–+
| 1    |
| 2    |
| 3    |
+–+
3 rows in set (0.00 sec)
mysql>

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明增加枚举类型
喜欢 (0)
[1034331897@qq.com]
分享 (0)