我是靠谱客的博主 友好夏天,最近开发中收集的这篇文章主要介绍Int Data Type Syntax,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Required Storage and Range for Integer Types Supported by MySQL

TypeStorage (Bytes)Minimum Value SignedMinimum Value UnsignedMaximum Value SignedMaximum Value Unsigned
TINYINT1-1280127255
SMALLINT2-3276803276765535
MEDIUMINT3-83886080838860716777215
INT4-2147483648021474836474294967295
BIGINT8-2的63方 02的63方-12的64方-1

 

TINYINT

TINYINT[(M)] [UNSIGNED] [ZEROFILL]

A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

 

SMALLINT

A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.

 

MEDIUMINT

MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]

A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.

 

INT

INT[(M)] [UNSIGNED] [ZEROFILL]

A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

INTEGER

INTEGER[(M)] [UNSIGNED] [ZEROFILL]

This type is a synonym for INT.

 

BIGINT

BIGINT[(M)] [UNSIGNED] [ZEROFILL]

A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

SERIAL

SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.

DEMO

create table serial_test (id SERIAL);

从图可知,是无符号的bigint类型,不能为空,主键,自动增长

1个表中,指定多个字段为serial,会报错(Incorrect table definition; there can be only one auto column and it must be defined as a key)

 

BOOL, BOOLEAN

These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true.

0是fase,不为0是true

 

 

 

 

最后

以上就是友好夏天为你收集整理的Int Data Type Syntax的全部内容,希望文章能够帮你解决Int Data Type Syntax所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部