如题所述
MySQL æ°æ®åºçvarcharç±»åå¨4.1以ä¸ççæ¬ä¸çæ大é¿åº¦éå¶ä¸º255ï¼å
¶æ°æ®èå´å¯ä»¥æ¯0~255æ1~255ï¼æ ¹æ®ä¸åçæ¬æ°æ®åºæ¥å®ï¼ãå¨ MySQL5.0以ä¸ççæ¬ä¸ï¼varcharæ°æ®ç±»åçé¿åº¦æ¯æå°äº65535ï¼ä¹å°±æ¯è¯´å¯ä»¥åæ¾65532个åèçæ°æ®ï¼èµ·å§ä½åç»æä½å å»äº3个å èï¼ä¹å°±æ¯è¯´ï¼å¨4.1æ以ä¸çæ¬ä¸éè¦ä½¿ç¨åºå®çTEXTæBLOBæ ¼å¼åæ¾çæ°æ®å¯ä»¥ä½¿ç¨å¯åé¿çvarcharæ¥åæ¾ï¼è¿æ ·å°±è½ææçåå°æ°æ®åºæ 件ç大å°ã
MySQL æ°æ®åºçvarcharç±»åå¨4.1以ä¸ççæ¬ä¸,nvarcharï¼åå¨çæ¯Unicodeæ°æ®ç±»åçå符ï¼ä¸ç®¡æ¯ä¸ä¸ªå符è¿æ¯ä¸ä¸ªæ±å,é½å为2个åè ï¼ä¸è¬ç¨ä½ä¸ææè å ¶ä»è¯è¨è¾å ¥ï¼è¿æ ·ä¸å®¹æä¹±ç ;varchar: æ±åæ¯2个åè,å ¶ä»å符å为1个åè ï¼varcharéåè¾å ¥è±æåæ°åã
4.0çæ¬ä»¥ä¸ï¼varchar(20)ï¼æçæ¯20åèï¼å¦æåæ¾UTF8æ±åæ¶ï¼åªè½å6个ï¼æ¯ä¸ªæ±å3åèï¼ ï¼5.0çæ¬ä»¥ä¸ï¼varchar(20)ï¼æçæ¯20å符ï¼æ 论åæ¾çæ¯æ°åãåæ¯è¿æ¯UTF8æ±åï¼æ¯ä¸ªæ±å3åèï¼ï¼é½å¯ä»¥åæ¾20个ï¼æ大大å°æ¯65532åè ï¼varchar(20)å¨Mysql4ä¸æ大ä¹ä¸è¿æ¯20个åè,ä½æ¯Mysql5æ ¹æ®ç¼ç ä¸å,åå¨å¤§å°ä¹ä¸åï¼å ·ä½æ以ä¸è§åï¼
a) åå¨éå¶
varchar å段æ¯å°å®é å 容åç¬åå¨å¨èç°ç´¢å¼ä¹å¤ï¼å 容å¼å¤´ç¨1å°2个åè表示å®é é¿åº¦ï¼é¿åº¦è¶ è¿255æ¶éè¦2个åèï¼ï¼å æ¤æ大é¿åº¦ä¸è½è¶ è¿65535ã
b) ç¼ç é¿åº¦éå¶
å符类åè¥ä¸ºgbkï¼æ¯ä¸ªå符æå¤å 2个åèï¼æ大é¿åº¦ä¸è½è¶ è¿32766;
å符类åè¥ä¸ºutf8ï¼æ¯ä¸ªå符æå¤å 3个åèï¼æ大é¿åº¦ä¸è½è¶ è¿21845ã
è¥å®ä¹çæ¶åè¶ è¿ä¸è¿°éå¶ï¼åvarcharå段ä¼è¢«å¼ºè¡è½¬ä¸ºtextç±»åï¼å¹¶äº§çwarningã
c) è¡é¿åº¦éå¶
导è´å®é åºç¨ä¸varcharé¿åº¦éå¶çæ¯ä¸ä¸ªè¡å®ä¹çé¿åº¦ã MySQLè¦æ±ä¸ä¸ªè¡çå®ä¹é¿åº¦ä¸è½è¶ è¿65535ãè¥å®ä¹ç表é¿åº¦è¶ è¿è¿ä¸ªå¼ï¼åæ示
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBsã
---------------------------------------------------------------------
mysqlçvacharå段çç±»åè½ç¶æ大é¿åº¦æ¯65535ï¼ä½æ¯å¹¶ä¸æ¯è½åè¿ä¹å¤æ°æ®ï¼æ大å¯ä»¥å°65533ï¼ä¸å 许é空å段çæ¶åï¼ï¼å½å 许é空å段çæ¶ååªè½å°65532ã
åèé¾æ¥ï¼http://zhidao.baidu.com/question/519664500345535085.html
MySQL æ°æ®åºçvarcharç±»åå¨4.1以ä¸ççæ¬ä¸,nvarcharï¼åå¨çæ¯Unicodeæ°æ®ç±»åçå符ï¼ä¸ç®¡æ¯ä¸ä¸ªå符è¿æ¯ä¸ä¸ªæ±å,é½å为2个åè ï¼ä¸è¬ç¨ä½ä¸ææè å ¶ä»è¯è¨è¾å ¥ï¼è¿æ ·ä¸å®¹æä¹±ç ;varchar: æ±åæ¯2个åè,å ¶ä»å符å为1个åè ï¼varcharéåè¾å ¥è±æåæ°åã
4.0çæ¬ä»¥ä¸ï¼varchar(20)ï¼æçæ¯20åèï¼å¦æåæ¾UTF8æ±åæ¶ï¼åªè½å6个ï¼æ¯ä¸ªæ±å3åèï¼ ï¼5.0çæ¬ä»¥ä¸ï¼varchar(20)ï¼æçæ¯20å符ï¼æ 论åæ¾çæ¯æ°åãåæ¯è¿æ¯UTF8æ±åï¼æ¯ä¸ªæ±å3åèï¼ï¼é½å¯ä»¥åæ¾20个ï¼æ大大å°æ¯65532åè ï¼varchar(20)å¨Mysql4ä¸æ大ä¹ä¸è¿æ¯20个åè,ä½æ¯Mysql5æ ¹æ®ç¼ç ä¸å,åå¨å¤§å°ä¹ä¸åï¼å ·ä½æ以ä¸è§åï¼
a) åå¨éå¶
varchar å段æ¯å°å®é å 容åç¬åå¨å¨èç°ç´¢å¼ä¹å¤ï¼å 容å¼å¤´ç¨1å°2个åè表示å®é é¿åº¦ï¼é¿åº¦è¶ è¿255æ¶éè¦2个åèï¼ï¼å æ¤æ大é¿åº¦ä¸è½è¶ è¿65535ã
b) ç¼ç é¿åº¦éå¶
å符类åè¥ä¸ºgbkï¼æ¯ä¸ªå符æå¤å 2个åèï¼æ大é¿åº¦ä¸è½è¶ è¿32766;
å符类åè¥ä¸ºutf8ï¼æ¯ä¸ªå符æå¤å 3个åèï¼æ大é¿åº¦ä¸è½è¶ è¿21845ã
è¥å®ä¹çæ¶åè¶ è¿ä¸è¿°éå¶ï¼åvarcharå段ä¼è¢«å¼ºè¡è½¬ä¸ºtextç±»åï¼å¹¶äº§çwarningã
c) è¡é¿åº¦éå¶
导è´å®é åºç¨ä¸varcharé¿åº¦éå¶çæ¯ä¸ä¸ªè¡å®ä¹çé¿åº¦ã MySQLè¦æ±ä¸ä¸ªè¡çå®ä¹é¿åº¦ä¸è½è¶ è¿65535ãè¥å®ä¹ç表é¿åº¦è¶ è¿è¿ä¸ªå¼ï¼åæ示
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBsã
---------------------------------------------------------------------
mysqlçvacharå段çç±»åè½ç¶æ大é¿åº¦æ¯65535ï¼ä½æ¯å¹¶ä¸æ¯è½åè¿ä¹å¤æ°æ®ï¼æ大å¯ä»¥å°65533ï¼ä¸å 许é空å段çæ¶åï¼ï¼å½å 许é空å段çæ¶ååªè½å°65532ã
åèé¾æ¥ï¼http://zhidao.baidu.com/question/519664500345535085.html
温馨提示:答案为网友推荐,仅供参考