Monday, August 21, 2006 2:56 AM
I need to create constraint in column to add only alphabet .
like "adc" ,"sdfsd" and not "1234adfd".plz reply soon.
Monday, August 21, 2006 3:28 AM
check this out.
create table mytable
ALTER TABLE MYTABLE
mytext not like '%[0-9]%'
insert mytable(mytext) values('hello') -- suceed
insert mytable(mytext) values('hello2') --- will fail
select * from mytable
Tuesday, August 22, 2006 7:53 PMA better alternative would be to check only for the valid set of characters. This is typically more robust. For example, the check like '%[0-9]%' will allow other characters like ', _, " or extended characters. So do instead:mytext like '[abcedefghijklmnopqrstuvwxyzABCEDEFGHIJKLMNOPQRSTUVWXYZ]'Note that the above way of writing the LIKE pattern is also safer than '[a-zA-Z]' because the latter expression is collation dependent.