I have another Question comming up, while solving some problems with postgreSQL. Is there any option, to check (in a check statement), if a varchar() contains an upper case character? (I want that my table only holds Strings with at least one upper case letter.) Thats how my table look:
x
CREATE TABLE test(
id integer PRIMARY KEY,
code varchar(255) not null,
CHECK ((char_length(code) >= 10) && check for upperCase?)
);
Does anyone have a tip how to solve this? Regards, Lukas
Advertisement
Answer
Make sure there are at least one non-lower case character:
CHECK ((char_length(code) >= 10) and code <> lower(code))