跳转到主要内容

数字

整数数据类型

基本整数数字数据类型。

名称别名存储大小最小值最大值Description
TINYINTINT81 字节-128127
SMALLINTINT162 字节-3276832767
INTINT324 字节-21474836482147483647
BIGINTINT648 字节-92233720368547758089223372036854775807
tip

如果你想要无符号整数,请使用 UNSIGNED 约束,这与 MySQL 兼容,例如:


CREATE TABLE test_numeric(tiny TINYINT, tiny_unsigned TINYINT UNSIGNED)

浮点数据类型

基本的 Float32/Float64 数据类型。

名称别名存储大小最小值最大值Description
FLOAT4 字节-3.40282347e+383.40282347e+38
DOUBLE8 字节-1.7976931348623157E+3081.7976931348623157E+308

函数

查看 数字函数

Examples

CREATE TABLE test_numeric
(
tiny TINYINT,
tiny_unsigned TINYINT UNSIGNED,
smallint SMALLINT,
smallint_unsigned SMALLINT UNSIGNED,
int INT,
int_unsigned INT UNSIGNED,
bigint BIGINT,
bigint_unsigned BIGINT UNSIGNED,
float FLOAT,
double DOUBLE
);

DESC test_numeric;
+-------------------+-------------------+------+---------+-------+
| Field | Type | Null | Default | Extra |
+-------------------+-------------------+------+---------+-------+
| tiny | TINYINT | NO | 0 | |
| tiny_unsigned | TINYINT UNSIGNED | NO | 0 | |
| smallint | SMALLINT | NO | 0 | |
| smallint_unsigned | SMALLINT UNSIGNED | NO | 0 | |
| int | INT | NO | 0 | |
| int_unsigned | INT UNSIGNED | NO | 0 | |
| bigint | BIGINT | NO | 0 | |
| bigint_unsigned | BIGINT UNSIGNED | NO | 0 | |
| float | FLOAT | NO | 0 | |
| double | DOUBLE | NO | 0 | |
+-------------------+-------------------+------+---------+-------+