mysqlÖÐvarcharºÍvarchar2µÄÇø±ð
mysql ÖÐ varchar ºÍ varchar2 µÄÖ÷ÒªÇø±ðÔÚÓÚ¼æÈÝÐԺ͹æÄ£ÏÞÖÆ¡£varchar ÊÇ mysql ¹ÌÓеÄÊý¾ÝÀàÐÍ£¬³¤¶ÈÏÞÖÆΪ 255 ¸ö×Ö·û£¬ÓëÆäËûÊý¾Ý¿â²»¼æÈÝ¡£varchar2 ÊÇ oracle ÒýÈëµÄÊý¾ÝÀàÐÍ£¬×÷Ϊ varchar µÄÓÖÃû±£´æ£¬³¤¶ÈÏÞÖÆΪ 65535 ¸ö×Ö½Ú£¬ÓÃÓÚ´æ´¢´óÎı¾×Ö·û´®¡£ÔÚÆäËûÊý¾Ý¿âÖУ¬ËüÃÇ¿ÉÄܱ£´æϸ΢²î±ð¡£
MySQL ÖÐ VARCHAR ºÍ VARCHAR2 µÄÇø±ð
MySQL ÖÐµÄ VARCHAR ºÍ VARCHAR2 ¶¼Êǿɱ䳤¶ÈµÄÊý¾ÝÀàÐÍ£¬ÓÃÓÚ´æ´¢×Ö·û´®Êý¾Ý¡£ËüÃÇÖ®¼äµÄÖ÷ÒªÇø±ðÔÚÓÚ¼æÈÝÐԺ͹æÄ£ÏÞÖÆ¡£
¼æÈÝÐÔ
VARCHAR ÊÇ MySQL ¹ÌÓеÄÊý¾ÝÀàÐÍ£¬ÓëÆäËû¹ØϵÐÍÊý¾Ý¿âÖÎÀíϵͳ£¨Èç Oracle ºÍ PostgreSQL£©²»¼æÈÝ¡£
VARCHAR2 ÊÇ Oracle Êý¾Ý¿âÖÐÒýÈëµÄÊý¾ÝÀàÐÍ£¬Ò²±»ÆäËûÊý¾Ý¿â½ÓÄÉ¡£ÔÚ MySQL ÖУ¬Ëü×÷Ϊ VARCHAR µÄÓÖÃû±£´æ£¬Òò´ËËüÃǾßÓÐÏàͬµÄ¼æÈÝÐԺ͹¦Ð§¡£
¹æÄ£ÏÞÖÆ
VARCHAR ÔÚ MySQL Öеij¤¶ÈÏÞÖÆΪ 255 ¸ö×Ö·û¡£
VARCHAR2 ÔÚ Oracle Öеij¤¶ÈÏÞÖÆΪ 4000 ¸ö×Ö½Ú£¬¶øÔÚ MySQL Öеij¤¶ÈÏÞÖÆΪ 65535 ¸ö×Ö½Ú¡£
ʹÓó¡¾°
ÓÉÓÚ VARCHAR2 ÌṩÁ˸ü³¤µÄ³¤¶ÈÏÞÖÆ£¬Ëüͨ³£ÓÃÓÚ´æ´¢´óÎı¾×Ö·û´®£¬ÈçÎÄÕ»ò²úÆ·ÐÎò¡£VARCHAR ͨ³£ÓÃÓڽ϶̵Ä×Ö·û´®£¬ÈçÃû³Æ»òµç×ÓÓʼþµØµã¡£
ʾÀý
-- VARCHAR CREATE TABLE customer_data ( name VARCHAR(255) ); -- VARCHAR2 CREATE TABLE customer_data_alt ( name VARCHAR2(4000) );
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄʾÀýÖУ¬customer_data ±íʹÓà VARCHAR À´´æ´¢¿Í»§ÐÕÃû£¬×î¶à 255 ¸ö×Ö·û¡£customer_data_alt ±íʹÓà VARCHAR2 À´´æ´¢¸ü³¤µÄÐÕÃû£¬×î¶à 4000 ¸ö×Ö·û¡£
×¢ÖØ£ºËäÈ» VARCHAR ºÍ VARCHAR2 ÔÚ MySQL ÖÐÊǵÈЧµÄ£¬µ«ÔÚÆäËûÊý¾Ý¿âÖпÉÄܻᱣ´æϸ΢²î±ð¡£Ê¼ÖÕ½¨ÒéÔÚʹÓÃ֮ǰ¼ì²éÿ¸öÌض¨Ãü¾Ý¿âµÄÎĵµ¡£
ÒÔÉϾÍÊÇmysqlÖÐvarcharºÍvarchar2µÄÇø±ðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡