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 型別的最大長度限制MySql型別
- MySQL 中 VARCHAR 最大長度及 CHAR 和 VARCHAR 的區別MySql
- MySQL中欄位型別與合理的選擇欄位型別;int(11)最大長度是多少?varchar最大長度是多少?MySql型別
- DM8 varchar型別長度型別
- mysql的varchar欄位最大長度真的是65535嗎?MySql
- 型別長度大於最大值型別
- MySQL VARCHAR型別欄位到底可以定義多長MySql型別
- mysql字元型別varchar()比較MySql字元型別
- MySQL動態修改varchar長度的方法MySql
- 例項操作mysql varchar型別求和MySql型別
- MySQL中CHAR和VARCHAR區別MySql
- 談MySQL中char varchar區別MySql
- MySQL資料型別操作(char與varchar)MySql資料型別
- 面試官:MySQL 中 varchar(n) 中 n 最大取值為多少?面試MySql
- MySQL CHAR和VARCHAR資料型別介紹MySql資料型別
- MySQL字元資料型別char與varchar的區別MySql字元資料型別
- NTMySQL中varchar和char型別的區別heeMySql型別
- MySQL int型別長度的意義是什麼MySql型別
- 12c 新特性之varchar2,nvarchar2型別大小測試型別
- MySQL中varchar和char定義長度是字元,與Oracle nvarchar2類似MySql字元Oracle
- 資料型別及長度資料型別
- mysql變長型別欄位varchar值更新變長或變短底層檔案儲存原理MySql型別
- varchar後面是否定義長度,還是有區別的
- Mysql中varchar與char的區別以及varchar(30)中的30代表的涵義MySql
- SQL SERVER 查詢表的欄位名、資料型別和最大長度SQLServer資料型別
- 測試 mysql 的最大連線數MySql
- Oracle CHAR,VARCHAR,VARCHAR2,nvarchar型別的區別與使用Oracle型別
- 測試Java中的long,int基本型別Java型別
- 【轉載】詳解 MySQL int 型別的長度值問題MySql型別
- [轉載] 詳解 MySQL int 型別的長度值問題MySql型別
- oracle中number型欄位長度、精度及實際儲存狀態測試(zt)Oracle
- Mysql BLOB、BLOB與TEXT區別及效能影響、將BLOB型別轉換成VARCHAR型別MySql型別
- MySQL中資料型別(char(n)、varchar(n)、nchar(n)、nvarchar(n)的區別)MySql資料型別
- 敏捷開發中的7種測試型別敏捷型別
- 【基礎】Oracle CHAR,VARCHAR,VARCHAR2,nvarchar型別的區別與使用Oracle型別
- mysql儲存資料,varchar型別中的資料變成了科學計數法?MySql型別
- Oracle 修改欄位型別和長度Oracle型別
- 資料庫text型別的長度?資料庫型別