日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql decimal(6_MySQL(六) decimal数据默认处理

發布時間:2023/12/10 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql decimal(6_MySQL(六) decimal数据默认处理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

create table decimal_test(

id int auto_increment PRIMARY key,

score decimal(5,2) -- 取值范圍是 -999.99 到 999.99

);

decimal(M,D)M=整數位+小數位

-- 整數的位數必須小于等于m-d,不然報錯。小數的位數可以大于d位。多出d位時會做四舍五入,截取到d位。

-- 以上均不包括小數點、符號的位數。數字的總長度是m位,保存后的小數位最多是d位。如果保存后是整數,小數位不會補0。

-- 以下測試版本是5.7.14

select * from decimal_test;

-- 正數:

insert into decimal_test(score) VALUES(1.23); -- 1.23

insert into decimal_test(score) VALUES(123.45); -- 123.45

insert into decimal_test(score) VALUES(123.455); -- 123.46

insert into decimal_test(score) VALUES(123.451); -- 123.45

insert into decimal_test(score) VALUES(123.451123); -- 123.45

insert into decimal_test(score) VALUES(12345.451123); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(9999.451123); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(999.451123234324); -- 999.45

insert into decimal_test(score) VALUES(999.999999999); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(999.99123); -- 999.99

-- 負數:

insert into decimal_test(score) VALUES(-1.23); -- -1.23

insert into decimal_test(score) VALUES(-12.34); -- -12.34

insert into decimal_test(score) VALUES(-123.45); -- -123.45

insert into decimal_test(score) VALUES(-999.45); -- -999.45

insert into decimal_test(score) VALUES(-12343); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(12343); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(1234); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(123); -- 123

insert into decimal_test(score) VALUES(-123); -- -123

insert into decimal_test(score) VALUES(-999.99); -- -999.99

insert into decimal_test(score) VALUES(-9990.99); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(-1234.99); -- Out of range value for column 'score'

insert into decimal_test(score) VALUES(-1234); -- Out of range value for column 'score'

select VERSION() ; --?5.6.30

總結

以上是生活随笔為你收集整理的mysql decimal(6_MySQL(六) decimal数据默认处理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。