mysql数据库-字段类型

后端 / 2021-08-23

数值类型

整型

  • tinyint(1字节)
  • smallint(2字节)
  • mediumint(3字节)
  • int(4字节)
  • bigint(8字节)

小数类型

  • float(4字节)
  • double(8字节)
  • decimal(不确定)

时间日期

  • date(年 月 日)
  • time(时 分 秒)
  • datetime(年 月 日 时 分 秒) YYYY-MM-DD - HH:mm:ss
  • timeStamp 时间戳
  • year 年
  • month 月
  • day

字符串类型

  • char(0-255)固定空间 身份证 手机号 等
  • varchar(0-2^16-1)根据实际情况分配空间(需要用3个字节来记录使用了多少空间)
  • text(0-2^16-1)
  • longtext(0-2^32-1)

二进制数据

  • blob(0-2^16-1)
  • longblob(0-2^32-1)

位类型

  • it(1) 1位
  • bit(2) 2位
  • bit(M) m位

总结

image.png