josephok
V2EX  ›  问与答

MySQL DECIMAL类型

  •  
  •   josephok · Aug 29, 2013 · 2564 views
    This topic created in 4687 days ago, the information mentioned may be changed or developed.
    请问,MySQL中DECIMAL类型的小数点是否占用空间?比如DECIMAL(9,9)是占用8个字节还是9个字节?
    3 replies    1970-01-01 08:00:00 +08:00
    timonwong
        1
    timonwong  
       Aug 29, 2013
    按总数算,一个9个digit,因此用4字节存放。
    josephok
        2
    josephok  
    OP
       Aug 29, 2013
    我的问题写错了,是DECIMAL(18,9)
    timonwong
        3
    timonwong  
       Aug 29, 2013
    18 // 9 = 2
    18 % 9 = 0
    2*4=8字节
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1020 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:13 · PVG 03:13 · LAX 12:13 · JFK 15:13
    ♥ Do have faith in what you're doing.