Detailed explanation of the decimal padding problem of decimal data type in MySQL

Detailed explanation of the decimal padding problem of decimal data type in MySQL

Preface

During the development process, we often use the decimal data type. Because decimal is an accurate data type in MySQL.

The data types in MySQL include: float, double and other imprecise data types and decimal, which are precise data types.

Difference: For float, double and other inexact types, approximate values ​​are stored in the DB.

Decimal stores the exact original value in the form of a string.

Introduction to decimal:

decimal(a,b)

Where: a specifies the maximum number of decimal digits that can be stored to the left and right of the decimal point, with a maximum precision of 38. b specifies the maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal places must be a value between 0 and a. The default number of decimal places is 0.

Note: DECIMAL data types are used in calculations that require very high precision. These types allow the precision and counting method of the values ​​to be specified as selection parameters. Precision here refers to the total number of significant digits stored for the value, while the count method indicates the number of digits after the decimal point.

question

When the length of the decimal type is less than 14, when inserting data into the decimal type field, the invalid decimal 0 will be automatically removed. Only when the length of the decimal type is greater than or equal to 14 digits, the invalid 0 in the decimal place will be retained and the decimal places will be automatically filled.

insert image description here

insert image description here

Notice

When the page is displayed, the data also needs to be formatted (decimal places), otherwise invalid 0s will be removed.

This is the end of this article about the detailed explanation of the decimal padding problem of the decimal data type in MySQL. For more relevant MySQL decimal padding content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief introduction to the usage of decimal type in MySQL
  • The difference between Decimal type and Float Double in MySQL (detailed explanation)
  • Detailed explanation of the meaning of N and M in the MySQL data type DECIMAL(N,M)
  • Method to convert scientific notation numeric string to decimal type
  • Database data type float to C# type decimal, float data type conversion is invalid
  • Detailed explanation of the usage of DECIMAL in MySQL data type
  • Implementation of mysql decimal data type conversion
  • Detailed explanation of the usage of MySQL data type DECIMAL
  • In-depth explanation of the use and implementation of the Decimal type in the database

<<:  Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

>>:  Two ways to add a mask effect to the background image using background-color through CSS

Recommend

Mysql database scheduled backup script sharing

BackUpMysql.sh script #!/bin/bash PATH=/bin:/sbin...

Detailed explanation of three ways to import CSS files

There are three ways to introduce CSS: inline sty...

Analysis of the difference between absolute path and relative path in HTML

As shown in the figure: There are many files conne...

The complete usage of setup, ref, and reactive in Vue3 combination API

1. Getting started with setUp Briefly introduce t...

How to implement Docker to dynamically pass parameters to Springboot projects

background Recently, some friends who are new to ...

JDBC Exploration SQLException Analysis

1. Overview of SQLException When an error occurs ...

Upgrade MySQL 5.1 to 5.5.36 in CentOS

This article records the process of upgrading MyS...

How to completely delete the MySQL 8.0 service under Linux

Before reading this article, it is best to have a...

Detailed explanation of the basic use of centos7 firewall in linux

1. Basic use of firewalld start up: systemctl sta...

Several ways to remove the dotted box that appears when clicking a link

Here are a few ways to remove it: Add the link dir...

JS canvas realizes the functions of drawing board and signature board

This article shares the specific code of JS canva...

css Get all elements starting from the nth one

The specific code is as follows: <div id="...

The concept and characteristics of MySQL custom variables

A MySQL custom value is a temporary container for...