2

i need to create a table which has number of columns in which one column is varchar2 type.Now the problem is i need to set that particular column should support only alphabets. I've tried this code but this didn't get work can anybody help me!
thanks in advance!

CREATE TABLE test_1 ( test_id number, test_name varchar(50), CONSTRAINT name_test CHECK (test_name where regexp_like(test_name,'^([aA-zZ])+$')) ); 

3 Answers 3

1

Try:

CREATE TABLE test_1 ( test_id number, test_name varchar(50), CONSTRAINT name_test CHECK ( regexp_like(test_name,'^([aA-zZ])+$') ) ); 
Sign up to request clarification or add additional context in comments.

Comments

0

You are close, just use the function(which returns true/false).

CREATE TABLE z_test_1 ( test_id number, test_name varchar(50), CONSTRAINT name_test CHECK (regexp_like(test_name,'^([aA-zZ])+$')) ); 

Comments

0

http://www.dba-oracle.com/t_regular_expressions_constraints_updates_columns.htm

...CHECK (regexp_like(test_name,'^[[:alpha:]]+$') ) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.