SQL enables MYSQL users to allocate a filed in Decimal format with specific Precision and Scale numbers as:
SQL使MYSQL用户能够以Decimal格式分配具有特定Precision和Scale数字的字段:
CREATE TABLE test_table
(
test_column DECIMAL(6,4) NOT NULL
);
Now can you please let me know how I can do this in PHPMyAdmin as the field type has only Length/Value option available there?
现在,您可以告诉我如何在PHPMyAdmin中执行此操作,因为字段类型只有长度/值选项可用吗?
Thanks
谢谢
1 个解决方案
#1
16
Decimals can be added to a MySQL database by using the DECIMAL(M,D)
data type. This requires 2 arguments.
可以使用DECIMAL(M,D)数据类型将小数添加到MySQL数据库。这需要2个参数。
- M is the maximum number of digits, ranging from 1 to 65.
- M是最大位数,范围从1到65。
- D is the number of decimal places available, ranging from 0 to 30.
- D是可用的小数位数,范围从0到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.
请注意,对于小数位保留D位数,整数部分最多可以有M-D位数。因此,如果我们使用DECIMAL(6,4),则数字45.8239将是有效的,但456.12不会。
To use this in phpMyAdmin, you can do the following:
要在phpMyAdmin中使用它,您可以执行以下操作:
In the Length/Value
field type 6,4
without the parentheses.
在长度/值字段中键入6,4,不带括号。
results in a table structure like this:
得到一个像这样的表结构:
#1
16
Decimals can be added to a MySQL database by using the DECIMAL(M,D)
data type. This requires 2 arguments.
可以使用DECIMAL(M,D)数据类型将小数添加到MySQL数据库。这需要2个参数。
- M is the maximum number of digits, ranging from 1 to 65.
- M是最大位数,范围从1到65。
- D is the number of decimal places available, ranging from 0 to 30.
- D是可用的小数位数,范围从0到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.
请注意,对于小数位保留D位数,整数部分最多可以有M-D位数。因此,如果我们使用DECIMAL(6,4),则数字45.8239将是有效的,但456.12不会。
To use this in phpMyAdmin, you can do the following:
要在phpMyAdmin中使用它,您可以执行以下操作:
In the Length/Value
field type 6,4
without the parentheses.
在长度/值字段中键入6,4,不带括号。
results in a table structure like this:
得到一个像这样的表结构: