大家在设计数据库时,碰到 性别、状态等 这些 值比较固定的列时,数据类型定义通常如下:

 

通常都是采用 :

 

create table `XXX`  
(  
........  

 

sex int(1) not null comment '0:男 1:女',  

 

status int(1) not null comment '0:开启 1:关闭' 

 

) 

 

设置成枚举类型 ,也有它的道理,如下:

create table `XXX` 

( 

........ 

sex enum('','') not null , 

status enum('开启','关闭')  not null 

)

 

所以,一般来说,用第一种的比较多,如:

status int(1) not null comment '0:开启 1:关闭'

默认规则:状态值0用于关闭/阴性,1用于开启/阳性。

 

相关文章:

  • 2022-01-01
  • 2021-07-30
  • 2021-11-23
  • 2022-12-23
  • 2021-12-12
  • 2022-01-08
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-14
  • 2021-10-25
  • 2021-12-27
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案