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

MySQL unsigned attribute

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

Share

Shulou(Shulou.com)06/01 Report--

The integer type has an optional UNSIGNED attribute, which indicates that negative values are not allowed, which roughly doubles the upper limit of positive numbers.

You can use these integer types: TINYINT,SMALLINT,MEDIUMINT,INT,BIGINT. Respectively use 8pr 16pr 24pr 32 pr 64-bit storage space

The values they can store range from-2 (nmur1) to 2 (nmur1)-1, where n is the number of digits of the storage space.

As set up in the following table

Click (here) to collapse or open

CREATE TABLE `guo` (

`id`int (1) DEFAULT NULL

`qq` int (1) unsigned DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8id is not specified unsigned, and qq is specified unsigned

Insert data into the qq column first

According to the calculation, 2 (nMel 1)-1 is 2147483647.

Inserted successfully

Insert 2147483648 to indicate that it is out of range.

The unsigned column is inserted below, and the range should be

2 (nmur1) + 2 (nmur1)-1 is 4294967295

4294967296 is reported out of range.

Note that the int type definition is all int (1)

MySQL can specify a width for integers, such as int (11), which is meaningless for most applications: it does not limit the legal range of values, but simply specifies the number of characters used by some of MySQL's interactive tools, such as the MySQL command line client. For storage and computing, int (1) and int (20) are the same.

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