postgresql 中带有字母(非数字)的列的数据类型

Datatype for column with letters (non-numbers) in postgresql

哪种数据类型最适合在 table 中声明一个在 postgresql 中只能包含字母而不能包含数字的列?

最好的办法是在 varchar 上创建一个带有检查约束的域。

create domain textonly text check (value not similar to '%[0-9]%');

然后您可以将其用作防止数字的数据类型。

pagetest=# create table dtest (test textonly);
CREATE TABLE
pagetest=# insert into dtest values ('abc');
INSERT 0 1
pagetest=# insert into dtest values ('ab2c');
ERROR:  value for domain textonly violates check constraint "textonly_check"
pagetest=#