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

  • 相关阅读:
    JavaScript进行表单提交
    《构建之法》读书笔记2
    一个简单的session传值学习
    javascript相关正则收集
    LINQ中join语法大探究(多表关联),也有不少疑问
    c#排序算法详细探究
    js获得文本框中光标的位置
    linq to sql基本的操作(读,添加,删除,更新)
    不用保存直接读取文件内容
    终于搞明白ajax拉
  • 原文地址:https://www.cnblogs.com/upcyaya/p/6594020.html
Copyright © 2011-2022 走看看