梵小花的自留地

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

question 2

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,'[1]')) 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;

Correct Answer C

查看图例中对表CUSTOMERS 的定义和描述。你想给表CUSTOMERS的CUST_FIRST_NAME字段添加约束,以实现插入到表的数据中该字段不含有数字。以下哪个sql语句可以实现上述功能?

正确答案:C

解析:

本题考察的是REGEXP_LIKE以及正则表达式的用法。以下是oracle官方文档中对REGEXP_LIKE的说明。

  • REGEXP_LIKE is similar to the LIKE condition, except REGEXP_LIKE performs regular expression matching instead of the simple pattern matching performed by LIKE. This condition evaluates strings using characters as defined by the input character set.

  • This condition complies with the POSIX regular expression standard and the Unicode Regular Expression Guidelines.

  • REGEXP_LIKE使用正则表达式进行匹配,而不是执行简单的模式匹配,除此之外,它的用法和LIKE类似。这个条件使用输入字符串的定义字符集作为评估使用的字符集。

  • 这个条件符合POSIX正则表达式标准和Unicode正则表达式的指导方针。

  • 此题使用字符簇进行匹配,常用字符簇标准如下表:

  • 答案A:以大写字幕开头,B:不以数字开头,C:只包含字母,D:只包含数字。故答案C正确。

  1. 0-9 ↩︎

posted on 2017-03-21 14:04  梵小花的自留地  阅读(177)  评论(0编辑  收藏  举报