mysql怎么用枚举类型 sqlserver枚举类型( 五 )


b). 写入不同类型的测试数据
写入一条符合枚举类型定义的记录值:
复制代码代码示例:
root@localhost : test 11:22:35 INSERT INTO Mysqlops_enum(ID,Job_type,Work_City) VALUES(1,'QA','shanghai');
Query OK, 1 row affected (0.00 sec)
测试第二个枚举类型字Work_City是否允许为空记录值:
复制代码代码示例:
root@localhost : test 11:22:42 INSERT INTO Mysqlops_enum(ID,Job_type,Work_City) VALUES(2,'NA','');
Query OK, 1 row affected, 1 warning (0.00 sec)
root@localhost : test 11:22:48 SHOW WARNINGS;
+---------+------+------------------------------------------------+
| Level| Code | Message|
+---------+------+------------------------------------------------+
| Warning | 1265 | Data truncated for column 'Work_City' at row 1 |
+---------+------+------------------------------------------------+
1 row in set (0.00 sec)
测试第二个枚举类型字段Work_City是否允许存储NULL值:
复制代码代码示例:
root@localhost : test 11:22:53 INSERT INTO Mysqlops_enum(ID,Job_type,Work_City) VALUES(3,'Other',NULL);
ERROR 1048 (23000): Column 'Work_City' cannot be null
测试第一个枚举类型字段Job_type是否可以存储空白值:
复制代码代码示例:
root@localhost : test 11:22:59 INSERT INTO Mysqlops_enum(ID,Job_type,Work_City) VALUES(4,'','hangzhou');
Query OK, 1 row affected (0.00 sec)
测试第二个枚举类型字段Job_City如何处理没有在定义中描述的值域第一个枚举类型字段Work_Type的默认值没指定情况下,会默认填写那个值:
复制代码代码示例:
root@localhost : test 11:23:06 INSERT INTO Mysqlops_enum(ID,Work_City) VALUES(5,'ningbo');
Query OK, 1 row affected, 1 warning (0.00 sec)
root@localhost : test 11:23:13 SHOW WARNINGS;
+---------+------+------------------------------------------------+
| Level| Code | Message|
+---------+------+------------------------------------------------+
| Warning | 1265 | Data truncated for column 'Work_City' at row 1 |
+---------+------+------------------------------------------------+
1 row in set (0.00 sec)
测试第二个枚举类型字段未插入数据的情况下,是否能使用上字段定义中指定的默认值:
复制代码代码示例:
root@localhost : test 11:23:17 INSERT INTO Mysqlops_enum(ID,Job_type) VALUES(6,'DBA');
Query OK, 1 row affected (0.00 sec)
如何获取mysql中枚举类型的值如何获取mysql中枚举类型的值
mysql_query("SET NAMES 'utf-8'");
修改成
mysql_query("SET NAMES 'UTF8'");
【mysql怎么用枚举类型 sqlserver枚举类型】关于mysql怎么用枚举类型和sqlserver枚举类型的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读