View the Exhibit and examine the description of the CUSTOMERS table.
You want to add a constraint on the CUST_FIRST_NAME column of the CUSTOMERS table so that the value inserted in the column does not have numbers. Which SQL statement would you use to accomplish the task?
A.
ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,’^A-Z’))NOVALIDATE ;
B.
ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,’^[0-9]’))NOVALIDATE ;
C.
ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'[[:alpha:]]’))NOVALIDATE ;
D.
ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'[[:digit:]]’))NOVALIDATE ;
all of the options are not correct:
== TEST =====================================================================
drop table regexp_test;
create table regexp_test(text varchar2(5) check(regexp_like(text,’^A-Z’)));
insert into regexp_test values (‘A-Z-3′);
drop table regexp_test;
create table regexp_test(text varchar2(5) check(regexp_like(text,’^[0-9]’)));
insert into regexp_test values (‘1Z047′);
drop table regexp_test;
create table regexp_test(text varchar2(5) check(regexp_like(text,'[[:alpha:]]’)));
insert into regexp_test values (‘1Z047′);
drop table regexp_test;
create table regexp_test(text varchar2(5) check(regexp_like(text,'[[:digit:]]’)));
insert into regexp_test values (‘1Z047’);
== RESULT =========================================================================
table REGEXP_TEST dropped.
table REGEXP_TEST created.
1 rows inserted.
table REGEXP_TEST dropped.
table REGEXP_TEST created.
1 rows inserted.
table REGEXP_TEST dropped.
table REGEXP_TEST created.
1 rows inserted.
table REGEXP_TEST dropped.
table REGEXP_TEST created.
1 rows inserted.
This seems to work better:
CREATE TABLE regexp_test(text VARCHAR2(20) CHECK(REGEXP_LIKE(text,’^[a-zA-Z ]*$’)));
INSERT INTO regexp_test VALUES (‘Valid Entry’);
1 row inserted.
INSERT INTO regexp_test VALUES (‘Invalid 3ntry’);
02290. 00000 – “check constraint (%s.%s) violated”
or:
CREATE TABLE regexp_test(text VARCHAR2(20) check(regexp_like(text,’^[[:alpha:] ]*$’)));