161 字
1 分钟
性别在数据库怎样定义
参考链接
[Storing sex (gender) in database——stackoverflow](https://stackoverflow.com/questions/4175878/storing-sex-gender-in-database)性别在数据库怎样定义
> 1. **Int** - _aligned with Enum in code (1 = Male, 2 = Female, 3 = ...)_ > 2. **char(1)** - _Store __**m**__, __**f**__ or another single character identifier_ > 3. **Bit** _(boolean)_ - _is there an appropriate field name for this option?_ >按照国际标准来设定的话,显然性别肯定不止一个。以下是国际标准中的定义(ISO/IEC 5218)
- 0 = Not known;
- 1 = Male;
- 2 = Female;
- 9 = Not applicable.
那么boolean肯定是不适用国际标准的,char类型在枚举中性能、存储上非常有优势,所以优先选择char类型作为性别存储。
性别在数据库怎样定义
https://iszengmh.pages.dev/posts/性别在数据库怎样定义/