ITPub博客

首页 > IT职业 > IT职场 > set类型

set类型

原创 IT职场 作者:shenmingmingDBA 时间:2020-09-25 17:28:27 0 删除 编辑


mysql> create table t_col (col set ('a','b','c','d'));

Query OK, 0 rows affected (0.27 sec)


mysql> desc t_col

    -> ;

+-------+----------------------+------+-----+---------+-------+

| Field | Type                 | Null | Key | Default | Extra |

+-------+----------------------+------+-----+---------+-------+

| col   | set('a','b','c','d') | YES  |     | NULL    |       |

+-------+----------------------+------+-----+---------+-------+

1 row in set (0.02 sec)




mysql> show create table t_col\G;

*************************** 1. row ***************************

       Table: t_col

Create Table: CREATE TABLE `t_col` (

  `col` set('a','b','c','d') DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8

1 row in set (0.01 sec)


ERROR: 

No query specified



mysql> INSERT INTO T_COL VALUES('a,b'),('a,d,a'),('a,b'),('a,c'),('a');

Query OK, 5 rows affected (0.11 sec)

Records: 5  Duplicates: 0  Warnings: 0


mysql> select * from t_col;

+------+

| col  |

+------+

| a,b  |

| a,d  |

| a,b  |

| a,c  |

| a    |

+------+

5 rows in set (0.01 sec)


mysql> INSERT INTO T_COL VALUES('a,b'),('a,d,a'),('a,b'),('a,c'),('a'),('a,f');

ERROR 1265 (01000): Data truncated for column 'col' at row 6


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30166976/viewspace-2710442/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: ENUM枚举类型
请登录后发表评论 登录
全部评论

注册时间:2015-03-17

  • 博文量
    56
  • 访问量
    147922