zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-91题

    91. View the Exhibit and examine the structure of the PROMOTIONS table.

    Which two SQL statements would execute successfully? (Choose two.)

    A. UPDATE promotions

    SET promo_cost = promo_cost+ 100

    WHERE TO_CHAR(promo_end_date, 'yyyy') > '2000';

    B. SELECT promo_begin_date

    FROM promotions

    WHERE TO_CHAR(promo_begin_date,'mon dd yy')='jul 01 98';

    C. UPDATE promotions

    SET promo_cost = promo_cost+ 100
    WHERE promo_end_date > TO_DATE(SUBSTR('01-JAN-2000',8));

    D. SELECT TO_CHAR(promo_begin_date,'dd/month')

    FROM promotions

    WHERE promo_begin_date IN (TO_DATE('JUN 01 98'), TO_DATE('JUL 01 98'));

    Answer: AB

    答案解析:

    A答案:

     

    sh@TEST0924> UPDATE promotions
    2 SET promo_cost = promo_cost+ 100
    3 WHERE TO_CHAR(promo_end_date, 'yyyy') > '2000';
    42 rows updated.

    B答案:

    sh@TEST0924> SELECT promo_begin_date
    2 FROM promotions
    3 WHERE TO_CHAR(promo_begin_date,'mon dd yy')='jul 01 98';
    PROMO_BEG
    ---------
    01-JUL-98
    01-JUL-98
    01-JUL-98
    01-JUL-98
    01-JUL-98
    01-JUL-98
    6 rows selected.

    C答案:格式不匹配,需要使用格式符转换

    sh@TEST0924> UPDATE promotions
    2 SET promo_cost = promo_cost+ 100
    3 WHERE promo_end_date > TO_DATE(SUBSTR('01-JAN-2000',8));
    WHERE promo_end_date > TO_DATE(SUBSTR('01-JAN-2000',8))
    *
    ERROR at line 3:
    ORA-01861: literal does not match format string
    sh@TEST0924> select SUBSTR('01-JAN-2000',8) from dual;
    SUBS
    ----
    2000
    sh@TEST0924> UPDATE promotions
    2 SET promo_cost = promo_cost+ 100
    3 WHERE promo_end_date > TO_DATE(SUBSTR('01-JAN-2000',8),'yyyy');
    84 rows updated.
    D答案:TO_DATE转换的日期如果与默认格式不一样,需要使用格式符转换
    h@TEST0924> SELECT TO_CHAR(promo_begin_date,'dd/month')
    2 FROM promotions
    3 WHERE promo_begin_date IN (TO_DATE('JUN 01 98'), TO_DATE('JUL 01 98'));
    WHERE promo_begin_date IN (TO_DATE('JUN 01 98'), TO_DATE('JUL 01 98'))
    *
    ERROR at line 3:
    ORA-01858: a non-numeric character was found where a numeric was expected
    sh@TEST0924> SELECT TO_CHAR(promo_begin_date,'dd/month')
    2 FROM promotions
    3 WHERE promo_begin_date IN (TO_DATE('JUN 01 98','mon dd yy'),TO_DATE('JUL 01 98','mon dd yy'));
    no rows selected
  • 相关阅读:
    【字符编码】字符编码 && Base64编码算法
    【JVM】JVM系列之执行引擎(五)
    【JVM】JVM系列之类加载机制(四)
    【JVM】JVM系列之Class文件(三)
    【知识积累】DES算法之C#加密&Java解密
    appium多机并行测试
    Jenkins 传递自定义的参数
    python对ftp进行操作
    Linux下ftp服务器搭建
    appium +ios 判断元素是否存在,排除visible=“false”的数据
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317158.html
Copyright © 2011-2022 走看看