• 【每日一题之OCP-043】question 2


    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 ↩︎

  • 相关阅读:
    利用git上传到码云
    js 数组的方法总结
    什么是浏览器的回流和重绘以及如何减少回流和重绘
    数组的方法some和includes
    node.js中使用http-proxy-middleware请求转发给其它服务器
    什么是BFC
    如何用Github上传项目中的代码
    前端渲染与后端渲染的区别有哪些
    移动端路由的切换
    面试题
  • 原文地址:https://www.cnblogs.com/upcyaya/p/6594020.html
Copyright © 2020-2023  润新知