mysql限制小数位,如何使用phpMyAdmin在MySQL中指定小数精度和小数位数

SQL enables MySQL users to allocate a filed in Decimal format with specific Precision and Scale numbers as:

CREATE TABLE test_table

(

test_column DECIMAL(6,4) NOT NULL

);

How can I do this in phpMyAdmin as the field type has only length/value option available there?

解决方案

Decimals can be added to a MySQL database by using the DECIMAL(M,D) data type. This requires 2 arguments.

M is the maximum number of digits, ranging from 1 to 65.

D is the number of decimal places available, ranging from 0 to 30.

Note that with D digits reserved for decimal places, there can be at most M-D digits available for the integer part. So if we use DECIMAL(6,4), the number 45.8239 would be valid, but 456.12 would not.

To use this in phpMyAdmin, you can do the following:

In the Length/Value field type 6,4 without the parentheses.

dec9e52ec7b9bbf33985b2940b9644d7.png

results in a table structure like this:

o6wPH.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值