2
mysql | 类型和属性
source link: https://benpaodewoniu.github.io/2022/12/11/mysql14/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
数据库的列类型和属性。
名称 | 大小 |
---|---|
tinyint | 1 字节 |
smallint | 2 字节 |
mediumint | 3字节 |
int | 4 字节 |
bitint | 8 字节 |
float | 4 字节 |
double | 8 字节 |
decimal | 字符串类型的浮点数 「金融计算使用」 |
名称 | 大小 |
---|---|
char | 字符串固定大小 0 - 255 |
varchar | 可变字符串 0 - 65535 |
tinytext | 微型文本 2^8 - 1 |
text | 文本串 |
名称 | 大小 |
---|---|
date | YYYY-MM-DD |
time | HH:mm:ss |
datetime | YYYY-MM-DD HH:mm:ss |
timestamp | 时间戳 毫秒 |
year | 年份 |
名称 | 大小 |
---|---|
null | 没有值,未知 不要使用 null 进行运算 |
数据库的字段属性
- Unsigned
- 无符号整数
- 声明该列不能为负数
- zerofill
- 不足的位数使用 0 填充
- 自增 auto increment
- 通常用来设置主键
- 可自定义设置自增初始值和步长
- 非空 Null not null
- 设置是否非空
- 默认 default
- 设置默认值
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK