1
字母(非数字)列哪个数据类型是最好的声明中只能包含字母和数字没有在PostgreSQL中一个表中的列?数据类型与PostgreSQL的
字母(非数字)列哪个数据类型是最好的声明中只能包含字母和数字没有在PostgreSQL中一个表中的列?数据类型与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=#
谢谢:)你的答案做了一点修改就完成了。 –