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

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

问题描述

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

如何在 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天全站免登陆