Database postgresql中带有字母(非数字)的列的数据类型
对于在postgresql中只能包含字母而不能包含数字的表中声明列,哪种数据类型最合适?最好是在varchar上使用check约束创建一个域Database postgresql中带有字母(非数字)的列的数据类型,database,postgresql,database-schema,Database,Postgresql,Database Schema,对于在postgresql中只能包含字母而不能包含数字的表中声明列,哪种数据类型最合适?最好是在varchar上使用check约束创建一个域 create domain textonly text check (value not similar to '%[0-9]%'); 然后,您可以将其用作阻止数字的数据类型 pagetest=# create table dtest (test textonly); CREATE TABLE pagetest=# insert into dtest v
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=#
谢谢:)你的答案稍加修改就成功了。