MySQL 在mysql中存储负值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8644196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
storing negative value in mysql
提问by Hafiz
How can I store negative value in mysql decimal? I have data from DMS to Decimal having negative values, so it is decimal and negative. So what can I use to store such value?
如何在mysql十进制中存储负值?我有从 DMS 到 Decimal 的数据有负值,所以它是小数和负数。那么我可以用什么来存储这样的值呢?
回答by gbn
回答by Rossitten
In case you want to store a negative integer- (INT) will work nicely, unless it's not UNSIGNED.
如果您想存储一个负整数- ( INT) 会很好地工作,除非它不是 UNSIGNED。
https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
In case you want to store a negative decimal- (DECIMAL) is the way to go, as GBN mentioned above.
如果您想存储负小数- (DECIMAL)是要走的路,如上面提到的 GBN。
https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html
https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html