MySQL decimal、numeric資料類型介紹,decimalnumeric

來源:互聯網
上載者:User

MySQL decimal、numeric資料類型介紹,decimalnumeric
MySQL decimal、numeric資料類型介紹
DECIMAL(M, D)

例 如:salary DECIMAL(5,2)   

在這個例子中,5 (精度(precision)) 代表重要的十進位數位數目,2 (資料範圍(scale)) 代表在小數點後的數字位元。在這種情況下,因此,salary 列可以儲存的值範圍是從 -999.99 到 999.99。(即M代表總位元,D代表小數點後的位元);

 當插入的值超過儲存值的範圍會報錯:(例如將1000.03賦給salary時)

Out of range value for column 'salary' at row 1

 

當插入的值小數點後位元大於D時會警示告:(例如將99.8888賦給salary時)

Data truncated for column'salary' at row 1
numeric(M,D)與DECIMAL(M, D)一樣。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.