0
How to Allow Only Alphabets in Column â Create Check Constraint to Insert Only Alphabets
CREATE TABLE TestTable (ID INT, Name VARCHAR(100), CONSTRAINT NameCHECK (Name NOT LIKE '%[^A-Z]%')) GO -- This will be successful INSERT INTO TestTable (ID, Name) VALUES (1, 'Akwin Lopez') GO -- This will throw an error INSERT INTO TestTable (ID, Name) VALUES (1, 'Akwin Lopez 1') GO
1 Answer
- 1
You cannot give regular expressions in LIKE statement.
You can use :REGEXP_LIKE(Name,'[a-zA-Z] *') in oracle. Similar functions will be available for other databases.