Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一般来说,我为此选择 int 或 tinyint,但如果我选择 varchar,直接从数据库表中查看数据或查询数据时会更清楚。但是使用 varchar 会是一个好习惯吗?或者有什么好的做法?
谢谢!
出于索引的原因,使用小的数字列比使用 varchar 更好,varchar 的大小只能由枚举中有多少值来确定。如果您需要从数据库返回文本值,请将文本值存储在单独的查找表中,并在需要时加入。
实际上,这取决于您想要的枚举类型,基本上是为了引用我们使用的值int。
int