×ðÁú¿­Ê±

mysqlÖÐdecimalÊÇʲôÊý¾ÝÀàÐÍ

decimal ÊÇ mysql ÖÐÓÃÓÚ´æ´¢¶¨µãСÊýµÄ¸ß¾«¶ÈÊý¾ÝÀàÐÍ¡£ÆäÌصã°üÀ¨£º¾«¶È£¨ÓÉ (m, d) Ö¸¶¨£©¡¢¹æÄ£¡¢¾«¶È²»É¥Ê§¡¢´æ´¢¿Õ¼ä¡£Ëü³£ÓÃÓÚÐèÒª¸ß¾«¶ÈÇ®±ÒÅÌËãµÄ³¡¾°£¬ÈçÒøÐÐϵͳ¡¢»á¼ÆÈí¼þºÍµç×ÓÉÌÎñƽ̨¡£

ʲôÊÇ MySQL ÖÐµÄ DECIMAL Êý¾ÝÀàÐÍ£¿

DECIMAL ÊÇ MySQL ÖеÄÒ»ÖÖÊý¾ÝÀàÐÍ£¬ÓÃÓÚ´æ´¢¶¨µãСÊý¡£Ëü±È FLOAT »ò DOUBLE Êý¾ÝÀàÐ͸ü׼ȷ£¬ÓÉÓÚËüʹÓÃÀο¿µÄСÊýλÊý¡£

DECIMAL µÄÌص㣺

¾«¶È£ºDECIMAL СÊýλÊýµÄ¾«¶ÈÊÇÀο¿µÄ£¬ÓÉÊý¾Ý½ç˵ÖÐµÄ (M, D) ²ÎÊýÖ¸¶¨£¬ÆäÖУº

M£ºÐ¡Êýµã×ó±ßµÄλÊý£¨ÕûÊý²¿·Ö£©

D£ºÐ¡ÊýµãÓұߵÄλÊý£¨Ð¡Êý²¿·Ö£©

¹æÄ££ºDECIMAL ÔÊÐí´æ´¢µÄÖµ¹æÄ£ºÜ´ó£¬´Ó -10^38-1 µ½ 10^38-1¡£

¾«¶Èɥʧ£ºÓë FLOAT ºÍ DOUBLE ²î±ð£¬DECIMAL ÔÚ¾ÙÐÐËãÊõÔËËãʱ²»»áɥʧ¾«¶È¡£

´æ´¢¿Õ¼ä£ºDECIMAL Õ¼ÓÃÓë FLOAT ÏàͬµÄ´æ´¢¿Õ¼ä£¬µ«±È DOUBLE ÐèÒªµÄ¿Õ¼ä¸üÉÙ¡£

DECIMAL µÄÓÃ;£º

DECIMAL Êý¾ÝÀàÐͳ£ÓÃÓÚÐèÒª¸ß¾«¶ÈÇ®±ÒÅÌËãµÄ³¡¾°£¬ÀýÈ磺

ÒøÐÐϵͳ

»á¼ÆÈí¼þ

µç×ÓÉÌÎñƽ̨

ʾÀý£º

ÒÔÏÂÓï¾ä½¨ÉèÁËÒ»¸öÃûΪ “amount” µÄ DECIMAL ÁУ¬¾«¶ÈΪ (10, 2)£º

CREATE TABLE transactions (
  amount DECIMAL(10, 2) NOT NULL
);

µÇ¼ºó¸´ÖÆ

Õâ¸öÁпÉÒÔ´æ´¢×î¸ß¾«¶ÈΪÁ½Î»Ð¡Êý¡¢ÕûÊý²¿·Ö×î¶à 10 λÊý×ÖµÄÖµ¡£

ÒÔÉϾÍÊÇmysqlÖÐdecimalÊÇʲôÊý¾ÝÀàÐ͵ÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿