Home > Database > Mysql Tutorial > body text

How to use integers in MySQL

WBOY
Release: 2023-05-30 11:08:23
forward
1097 people have browsed it

 Integer type of MySQL data type

When making data types, the range of selection should be as small as possible to meet the needs. The smaller the scope, the less resources it takes up.

  mysql> create table stu(
  -> stuid  tinyint
  -> );
  Query OK, 0 rows affected (0.00 sec)
Copy after login

  Unsigned integer type unsigned There is no negative number in the unsigned integer type, and the unsigned integer is twice the integer.

  mysql> create table stu1(
  -> stuid  tinyint unsigned
  -> );
Copy after login

Integers support display width. The display width is the minimum number of display digits. For example, int(11) means that the integer is represented by at least 11 digits. If there are not enough digits, fill it with 0. Display width does not work by default and must be combined with zerofill to work. The display size of the integer does not depend on the display width, but uses 0 for leading padding when the value is not enough for the specified number of digits

  mysql> create table stu2(
  -> sutid int(5) zerofill
  -> );
Copy after login

The above is the detailed content of How to use integers in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template