How to Specify Decimal Precision and Scale Number in MySQL Database Using PHPMyAdmin

蓝咒 提交于 2020-01-12 06:54:32

问题


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
);

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?

Thanks


回答1:


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.

results in a table structure like this:



来源:https://stackoverflow.com/questions/23877487/how-to-specify-decimal-precision-and-scale-number-in-mysql-database-using-phpmya

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!