Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the numerical type in MYSQL data type storage

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

How to understand the numerical type of MYSQL data type storage, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Explore the storage of MYSQL numerical types and the interpretation method. On Engine of myisam [@ more@] 1. Environment version:

OS: LINUX AS4

MYSQL: 5.0.51a-log

ENGINE: Myisam DEFAULT CHARSET=latin1

two。 The numerical type objects studied in this chapter:

TINYINT 1 byte FIXED

SMALLINT 2-byte FIXED

MEDIUMINT 3-byte FIXED

INT, INTEGER 4-byte FIXED

BIGINT 8-byte FIXED

DECIMAL (MMagne) > = 4-byte FIXED

3. Numeric type: TINYINT SMALLINT MEDIUMINT INT BIGINT

These data access methods are all the same: high priority storage, symbol bits (0 positive, 1 negative)

Drop table if exists heyf

Create table heyf (id TINYINT) type myisam DEFAULT CHARSET=latin1

Insert into heyf values (10), (- 10)

System hexdump / opt/mysql/data/test/heyf.MYD

-

0000000 0afd 0000 0000 fd00 00f6 0000 0000

000000e

-

Where:

ROW1:

-

Fd: line header

0a: worth 10

-

ROW2:

-

Fd: line header

F6: complement with a value of-10

-

If it is a positive number, the first digit is "0". You can read it directly.

If it is a negative number and the first bit is "1", the value will be reversed by + 1 according to the usual method.

For example:

The original value is the original binary plus 1 decimal

F6-& gt 1111 0110-& gt 0000 1001-& gt 0000 1010-& gt 10

Several other types ask the reader to draw an example.

4. Numeric type: DECIMAL (MJN) or DECIMAL (M)

4.1 memory bit Computing

Allocate a minimum of 4 bytes of space, such as decimal (4 Jue 2), which can actually be represented by two bytes. But MYSQL still uses 4 bytes when allocating space. Fill the free part with 0

DECIMAL (MJN), if 9

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report