在 postgresql 中用于存储 firebase uid 的数据类型是什么

Which is the data type to use for storing a firebase uid in postgresql

我想将 firebase auth 生成的 uid 存储在 postgres 数据库中。因为它不是有效的 uuid,所以我不确定要选择哪种数据类型。主要是我不确定我应该使用 char 还是 varchar。

Firebase 身份验证 UID 只是字符串。这些字符串不包含任何数据——它们只是随机的。 varchar 似乎合适。

我会说使用 varchar 允许 uid 随着时间的推移而变化。从 Postgres 端看确实没有区别,请参阅 here:

Tip

There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead.