zoukankan      html  css  js  c++  java
  • 【每日一题之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 ↩︎

  • 相关阅读:
    row_number() over(partition by的用法
    java基础之--动态代理
    Java中主要有一下三种类加载器;
    HBase基本shell命令
    IntelliJ IDE 基础经验备案 四-查找快捷键
    Docker:5 扩展学习之安装mysql并且将数据挂载到本地磁盘
    Docker:4 扩展学习之修改docker容器配置
    nginx安装部署《简单版》
    Redis基础学习: 与外部交互的数据类型
    Redis基础学习: 内部数据结构
  • 原文地址:https://www.cnblogs.com/upcyaya/p/6594020.html
Copyright © 2011-2022 走看看