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.

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?

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 ;



Leave a Reply 3

Your email address will not be published. Required fields are marked *


bogdan

bogdan

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.

dames

dames

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”

dames

dames

or:
CREATE TABLE regexp_test(text VARCHAR2(20) check(regexp_like(text,’^[[:alpha:] ]*$’)));