极客时间返利平台,你可以在上边通过山月的链接购买课程,并添加我的微信 (shanyue94) 领取返现。
山月训练营之面试直通车 服务上线了,从准备简历、八股文准备、项目经历准备、面试、面经、面经解答、主观问题答复、谈薪再到入职的一条龙服务。

# 在数据库中一个字段如果是字符串类型的,那应该设置哪种数据类型

Issue

欢迎在 Gtihub Issue 中回答此问题: Issue 230 (opens new window)

以下答案仅说明在 postgres 中的情况:

在 postgres 有三种 varcharchar 以及 text,其中三者没有性能差异,见官方文档

Different from other database systems, in PostgreSQL, there is no performance difference among three character types. In most situation, you should use text or varchar, and varchar(n) if you want PostgreSQL to check for the length limit

所以,选择 text 是最好的方案

Last Updated: 11/27/2021, 6:11:48 PM