mysql中varchar型別最大長度測試
1.先看字符集為latin1時,每個字元應該是佔據一個byte
mysql> create table test(a varchar(65535)) engine=innodb charset=latin1;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(65533)) engine=innodb charset=latin1;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(65532)) engine=innodb charset=latin1;
Query OK, 0 rows affected (0.01 sec)
2.再看字符集為GBK時,每個字元應該佔據2個byte
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(32767)) engine=innodb charset=gbk;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(32766)) engine=innodb charset=gbk;
Query OK, 0 rows affected (0.00 sec)
3.當字符集為UTF8時,每個字元佔據了3個byte
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(65535)) engine=innodb charset=utf8;
ERROR 1074 (42000): Column length too big for column 'a' (max = 21845); use BLOB or TEXT instead
mysql> create table test(a varchar(21845)) engine=innodb charset=utf8;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(21844)) engine=innodb charset=utf8;
Query OK, 0 rows affected (0.00 sec)
最後,如果表中所有varchar型別的列長度總和超過了65535,建立表時也會報錯
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(22000),b varchar(22000),c varchar(22000)) charset=latin1 engine=innodb;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(65535)) engine=innodb charset=latin1;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(65533)) engine=innodb charset=latin1;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(65532)) engine=innodb charset=latin1;
Query OK, 0 rows affected (0.01 sec)
2.再看字符集為GBK時,每個字元應該佔據2個byte
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(32767)) engine=innodb charset=gbk;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(32766)) engine=innodb charset=gbk;
Query OK, 0 rows affected (0.00 sec)
3.當字符集為UTF8時,每個字元佔據了3個byte
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(65535)) engine=innodb charset=utf8;
ERROR 1074 (42000): Column length too big for column 'a' (max = 21845); use BLOB or TEXT instead
mysql> create table test(a varchar(21845)) engine=innodb charset=utf8;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
mysql> create table test(a varchar(21844)) engine=innodb charset=utf8;
Query OK, 0 rows affected (0.00 sec)
最後,如果表中所有varchar型別的列長度總和超過了65535,建立表時也會報錯
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)
mysql> create table test(a varchar(22000),b varchar(22000),c varchar(22000)) charset=latin1 engine=innodb;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10972173/viewspace-2153140/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 中 VARCHAR 最大長度及 CHAR 和 VARCHAR 的區別MySql
- DM8 varchar型別長度型別
- mysql的varchar欄位最大長度真的是65535嗎?MySql
- 面試官:MySQL 中 varchar(n) 中 n 最大取值為多少?面試MySql
- MySQL VARCHAR型別欄位到底可以定義多長MySql型別
- 例項操作mysql varchar型別求和MySql型別
- MySQL動態修改varchar長度的方法MySql
- MySQL資料型別操作(char與varchar)MySql資料型別
- MySQL中CHAR和VARCHAR區別MySql
- MySQL中資料型別(char(n)、varchar(n)、nchar(n)、nvarchar(n)的區別)MySql資料型別
- NTMySQL中varchar和char型別的區別heeMySql型別
- mysql變長型別欄位varchar值更新變長或變短底層檔案儲存原理MySql型別
- MySQL int型別長度的意義是什麼MySql型別
- Mysql BLOB、BLOB與TEXT區別及效能影響、將BLOB型別轉換成VARCHAR型別MySql型別
- mysql儲存資料,varchar型別中的資料變成了科學計數法?MySql型別
- Mysql varchar型別欄位為什麼經常定義為255MySql型別
- 測試 mysql 的最大連線數MySql
- [轉載] 詳解 MySQL int 型別的長度值問題MySql型別
- 【轉載】詳解 MySQL int 型別的長度值問題MySql型別
- 測試Java中的long,int基本型別Java型別
- 你知道 Mysql Varchar 型別為什麼人們預設設定 255 嗎MySql型別
- 資料庫text型別的長度?資料庫型別
- Oracle 修改欄位型別和長度Oracle型別
- MySQL varchar詳解MySql
- MySQL中int、char、varchar的效能淺談MySql
- 有夥伴基於 swagger 等介面文件自動生成基礎測試用例 (型別長度空) 嗎Swagger型別
- 軟體測試開發:常見測試型別概念型別
- 高效能MySQL第四章 Schema與資料型別優化 VARCHAR和CHARMySql資料型別優化
- 關於mysql設定varchar 欄位的預設值''和null的區別,以及varchar和char的區別MySqlNull
- Python單元測試框架pytest常用測試報告型別Python框架測試報告型別
- ORANCLE 資料已存在,修改欄位型別長度型別
- String字串的最大長度是多少?字串
- MySQL中資料型別的驗證MySql資料型別
- 軟體驗收測試 常見測試報告的型別測試報告型別
- Android Testing學習01 介紹 測試測什麼 測試的型別Android型別
- Oracle 中varchar2 和nvarchar2區別Oracle
- MySQL 字元型別MySql字元型別
- varchar和char的區別