MySQL 的 char 与 varchar
Mysql  /  houtizong 发布于 3年前   271
CREATE TABLE `varcharLessThan4` ( `lastName` varchar(3)) ;mysql> desc varcharLessThan4;+----------+---------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+----------+---------+------+-----+---------+-------+| lastName | char(3) | YES | | NULL | |+----------+---------+------+-----+---------+-------+1 row in set (0.01 sec)CREATE TABLE `charGreaterThan4` ( `firstName` char(4), `lastName` varchar(4)) ;mysql> desc charGreaterThan4;+-----------+------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------+------------+------+-----+---------+-------+| firstName | varchar(4) | YES | | NULL | || lastName | varchar(4) | YES | | NULL | |+-----------+------------+------+-----+---------+-------+2 rows in set (0.00 sec)CREATE TABLE `charLessThan4` ( `firstName` char(3), `lastName` varchar(4)) ;mysql> desc charLessThan4;+-----------+------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------+------------+------+-----+---------+-------+| firstName | char(3) | YES | | NULL | || lastName | varchar(4) | YES | | NULL | |+-----------+------------+------+-----+---------+-------+2 rows in set (0.00 sec)
Note that using CHAR will only speed up your access if the whole record is fixed size. That is, if you use any variable size object, you might as well make all of them variable size. You gain no speed by using a CHAR in a table that also contains a VARCHAR.
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接