如何使用phpMyAdmin在MySQL中指定小数精度和小数位数 [英] How to specify decimal precision and scale number in MySQL using phpMyAdmin

查看:647
本文介绍了如何使用phpMyAdmin在MySQL中指定小数精度和小数位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL使MySQL用户可以将Decimal格式的文件分配为特定的Precision和Scale编号,如下所示:

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

我该如何在phpMyAdmin中执行此操作,因为该字段类型仅具有长度/值选项?

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

推荐答案

可以使用DECIMAL(M,D)数据类型将小数点添加到MySQL数据库.这需要2个参数.

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

  • M是最大位数,范围为1到65.
  • D是可用的小数位数,范围从0到30.

请注意,由于D位保留为小数位,整数部分最多可以有M-D位可用.因此,如果我们使用DECIMAL(6,4),则数字45.8239将有效,而456.12则无效.

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.

要在phpMyAdmin中使用此功能,可以执行以下操作:

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

Length/Value字段中键入6,4,不带括号.

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

结果是这样的表结构:

这篇关于如何使用phpMyAdmin在MySQL中指定小数精度和小数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆