×ðÁú¿­Ê±¹ÙÍøµÇ¼

mysqlÖÐdecimalÔõôÓÃ

mysql ÖÐ decimal Êý¾ÝÀàÐÍÓÃÓÚÌåÏÖ׼ȷµÄСÊýºÍÇ®±ÒÖµ£¬Ìصã°üÀ¨£º×¼È·´æ´¢Ð¡Êý£¬²»Êܸ¡µãÊý¾ÝµÄÉáÈëÎó²îÓ°Ïì¡£¹æģȡ¾öÓÚ precision Öµ£¬ÀýÈç decimal(10, 2) µÄ¹æģΪ -9999999999.99 µ½ 9999999999.99¡£±È¸¡µãÊý¾ÝÀàÐ͸üÓÐÓÃÂÊ£¬ÓÉÓÚ´æ´¢µÄλÊý¸üÉÙ¡£

MySQL ÖÐ DECIMAL Êý¾ÝÀàÐ͵ÄʹÓÃ

DECIMAL Êý¾ÝÀàÐÍÓÃÓÚÌåÏÖ׼ȷµÄСÊýºÍÇ®±ÒÖµ£¬ËüÔÚ´ó´ó¶¼ÇéÐÎϱȸ¡µãÊý¾ÝÀàÐ͸üÊʺϡ£

Óï·¨

DECIMAL(precision, scale)

µÇ¼ºó¸´ÖÆ

precision£ºÖ¸¶¨Ãü×ÖµÄ×ÜλÊý£¬°üÀ¨Ð¡ÊýµãºóµÄλÊý¡£

scale£ºÖ¸¶¨Ð¡ÊýµãºóµÄλÊý¡£

ʾÀý

CREATE TABLE sales (
  price DECIMAL(10, 2)
);

µÇ¼ºó¸´ÖÆ

Õ⽫½¨ÉèÒ»¸öÃûΪ sales µÄ±í£¬ÆäÖÐ price ×Ö¶ÎÊÇÒ»¸ö DECIMAL Êý¾ÝÀàÐÍ£¬×ÜλÊýΪ 10£¬Ð¡ÊýµãºóÓÐ 2 λ¡£

Ìصã

׼ȷÐÔ£ºDECIMAL Êý¾ÝÀàÐÍ¿ÉÒÔ׼ȷ´æ´¢Ð¡Êý£¬²»Êܸ¡µãÊý¾ÝµÄÉáÈëÎó²îÓ°Ïì¡£

¹æÄ££ºDECIMAL Êý¾ÝÀàÐ͵Ĺæģȡ¾öÓÚ precision Öµ¡£ÀýÈ磬DECIMAL(10, 2) µÄ¹æģΪ -9999999999.99 µ½ 9999999999.99¡£

´æ´¢Ð§ÂÊ£ºDECIMAL Êý¾ÝÀàÐͱȸ¡µãÊý¾ÝÀàÐ͸üÓÐÓÃÂÊ£¬ÓÉÓÚ´æ´¢µÄλÊý¸üÉÙ¡£

×î¼Ñʵ¼ù

ʹÓà DECIMAL Êý¾ÝÀàÐÍʱ£¬Çë˼Á¿ÒÔÏÂ×î¼Ñʵ¼ù£º

½öÔÚÐèҪ׼ȷÅÌËãʱʹÓà DECIMAL¡£

Ñ¡ÔñºÏÊ浀 precision ºÍ scale£¬×èÖ¹²»ÐëÒªµÄ´æ´¢¿Õ¼äÆÌÕÅ¡£

¹ØÓÚÇ®±ÒÖµ£¬Ê¹ÓÃÕûÊý»ò¾ßÓÐÈ·¶¨Ð¡ÊýµãλÖÃµÄ DECIMAL£¬ÀýÈç DECIMAL(10, 2)¡£

×èÖ¹½« DECIMAL ÖµÓ븡µãÖµ»ìÏýʹÓã¬ÓÉÓÚÕâ¿ÉÄܻᵼÖÂÉáÈëÎó²î¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ