mysqlÖÐgenderÒªÓÃʲôÀàÐÍ
mysql ÖÐÌåÏÖÐÔ±ðµÄ×Ö¶ÎÀàÐÍ°üÀ¨£ºenum£ºÔ¤½ç˵ֵµÄö¾ÙÀàÐÍ£¬È·±£Êý¾ÝÒ»ÖÂÐÔ£»varchar(n)£º¿É±ä³¤¶È×Ö·û´®ÀàÐÍ£¬ÔÊÐí¸üÎÞаµÄÊý¾Ý£»tinyint£º8 λÕûÊýÀàÐÍ£¬¿ÉÌåÏÖ²¼¶ûÖµ»òÓÐÏÞÑ¡Ïî¡£
MySQL ÖÐÌåÏÖÐÔ±ðµÄ×Ö¶ÎÀàÐÍ
ÔÚ MySQL ÖУ¬ÌåÏÖÐÔ±ðµÄ×Ö¶ÎÀàÐÍͨ³£ÈçÏ£º
ENUM
ENUM ÀàÐÍ´æ´¢ÓÐÏÞÊýÄ¿µÄÒ»×éÔ¤½ç˵ֵ£¬ºÜÊÇÊÊÊÊÓÃÓÚÌåÏÖÀο¿Ñ¡Ï£¬ÀýÈçÐԱ𡣴ËÀàÐÍÈ·±£Êý¾ÝÒ»ÖÂÐÔºÍÍêÕûÐÔ¡£Óï·¨ÈçÏ£º
CREATE TABLE table_name ( gender ENUM('male', 'female', 'other') );
µÇ¼ºó¸´ÖÆ
VARCHAR(n)
VARCHAR(n) ÀàÐÍ´æ´¢¿É±ä³¤¶ÈµÄ×Ö·û´®£¬¿ÉÒÔÈÝÄÉí§ÒâÐÔ±ð±êʶ¡£Óë ENUM ²î±ð£¬ËüÔÊÐí¸üÎÞаµÄÊý¾Ý£¬µ«ÐèҪעÖØÊý¾ÝÒ»ÖÂÐÔºÍÍêÕûÐÔ¡£Óï·¨ÈçÏ£º
CREATE TABLE table_name ( gender VARCHAR(255) );
µÇ¼ºó¸´ÖÆ
TINYINT
TINYINT ÀàÐÍ´æ´¢ 8 λÕûÊý£¬¿ÉÒÔÌåÏÖ 0 µ½ 255 Ö®¼äµÄÊý×Ö¡£Ëüͨ³£ÓÃÓÚÌåÏÖ²¼¶ûÖµ»òÓÐÏÞÊýÄ¿µÄÑ¡ÏÀýÈçÐÔ±ð¡£Óï·¨ÈçÏ£º
CREATE TABLE table_name ( gender TINYINT(1) );
µÇ¼ºó¸´ÖÆ
Ñ¡Ôñ±ê×¼
Ñ¡ÔñºÏÊʵÄ×Ö¶ÎÀàÐÍÈ¡¾öÓÚÏêϸÐèÇó£º
ÈôÊÇÐÔ±ð¹æÄ£ÒÑÖªÇÒÀο¿£¬Ôò½¨ÒéʹÓà ENUM¡£
ÈôÊÇÔÊÐí¸üÎÞаµÄÊý¾Ý£¬Ôò¿ÉÒÔ˼Á¿ VARCHAR(n)¡£
ÈôÊÇÐèÒª´æ´¢²¼¶ûÖµ»òÓÐÏÞÊýÄ¿µÄÑ¡ÏÔò TINYINT ¿ÉÄÜÊǺÏÊʵġ£
ÒÔÉϾÍÊÇmysqlÖÐgenderÒªÓÃʲôÀàÐ͵ÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡