📜  MariaDB数据类型

📅  最后修改于: 2020-11-29 05:25:30             🧑  作者: Mango

MariaDB数据类型

以下是MariaDB中的数据类型列表:

  • 字符串数据类型
  • 数值数据类型
  • 日期/时间数据类型
  • 大对象数据类型

字符串数据类型

data type syntax maximum size explanation
char(size) maximum size of 255 characters. where size is the number of characters to store. fixed-length strings. space padded on right to equal size characters.
varchar(size) maximum size of 255 characters. where size is the number of characters to store. variable-length string.
tinytext(size) maximum size of 255 characters. where size is the number of characters to store.
text(size) maximum size of 65,535 characters. where size is the number of characters to store.
mediumtext(size) maximum size of 16,777,215 characters. where size is the number of characters to store.
longtext(size) maximum size of 4gb or 4,294,967,295 characters. where size is the number of characters to store.
binary(size) maximum size of 255 characters. where size is the number of binary characters to store. fixed-length strings. space padded on right to equal size characters.
varbinary(size) maximum size of 255 characters. where size is the number of characters to store. variable-length string.

日期/时间数据类型

data type syntax maximum size explanation
date values range from ‘1000-01-01’ to ‘9999-12-31’. displayed as ‘yyyy-mm-dd’.
datetime values range from ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. displayed as ‘yyyy-mm-dd hh:mm:ss’.
timestamp(m) values range from ‘1970-01-01 00:00:01’ utc to ‘2038-01-19 03:14:07’ utc. displayed as ‘yyyy-mm-dd hh:mm:ss’.
time values range from ‘-838:59:59’ to ‘838:59:59’. displayed as ‘hh:mm:ss’.
year[(2|4)] year value as 2 digits or 4 digits. default is 4 digits.

数值数据类型

data type syntax maximum size
bit very small integer value that is equivalent to tinyint(1).
signed values range from -128 to 127. unsigned values range from 0 to 255.
tinyint(m) very small integer value.
signed values range from -128 to 127. unsigned values range from 0 to 255.
smallint(m) small integer value.
signed values range from -32768 to 32767. unsigned values range from 0 to 65535.
mediumint(m) medium integer value.
signed values range from -8388608 to 8388607. unsigned values range from 0 to 16777215.
int(m) standard integer value.
signed values range from -2147483648 to 2147483647. unsigned values range from 0 to 4294967295.
integer(m) standard integer value.
signed values range from -2147483648 to 2147483647. unsigned values range from 0 to 4294967295.
bigint(m) big integer value.
signed values range from -9223372036854775808 to 9223372036854775807. unsigned values range from 0 to 18446744073709551615.
decimal(m,d) unpacked fixed point number.
m defaults to 10, if not specified.d defaults to 0, if not specified.
dec(m,d) unpacked fixed point number.
m defaults to 10, if not specified.
d defaults to 0, if not specified.
numeric(m,d) unpacked fixed-point number.
m defaults to 10, if not specified.d defaults to 0, if not specified.
fixed(m,d) unpacked fixed-point number.
m defaults to 10, if not specified.
d defaults to 0, if not specified.
float(m,d) single precision floating point number.
double(m,d) double precision floating point number.
double precision(m,d) double precision floating point number.
real(m,d) double precision floating point number.
float(p) floating point number.
bool synonym for tinyint(1)
boolean synonym for tinyint(1)

大对象(LOB)数据类型

data type syntax maximum size
tinyblob maximum size of 255 bytes.
blob(size) maximum size of 65,535 bytes.
mediumblob maximum size of 16,777,215 bytes.
longtext maximum size of 4gb or 4,294,967,295 characters.