• OCP-1Z0-051-V9.02-53题


    53. View the Exhibit and examine the data in the PROMOTIONS table.
    PROMO_BEGIN_DATE is stored in the default date format, dd-mon-rr.
    You need to produce a report that provides   the name, cost,  and start date of all promos in the POST
    category that were   launched before January 1,  2000.
    Which SQL statement would you use? 
    A. SELECT promo_name, promo_cost, promo_begin_date
    FROM promotions
    WHERE promo_category = 'post' AND promo_begin_date < '01-01-00';
    B. SELECT promo_name, promo_cost, promo_begin_date
    FROM promotions
    WHERE promo_cost LIKE 'post%' AND promo_begin_date < '01-01-2000';
    C. SELECT promo_name, promo_cost, promo_begin_date
    FROM promotions
    WHERE promo_category LIKE 'P%' AND promo_begin_date < '1-JANUARY-00'; 可以,但是like条件不满足
    D. SELECT promo_name, promo_cost, promo_begin_date
    FROM promotions
    WHERE promo_category LIKE '%post%' AND promo_begin_date < '1-JAN-00';
    Answer: D
    答案解析:

    在表达式中,Oracle Server 可以自动执行以下转换:
    从 VARCHAR2 或CHAR隐式转换为NUMBER
    从VARCHAR2 或CHAR隐式转换为DATE,但必须符合日期的规定的格式。

    Oracle Server  可以在表达式中自动执行数据类型转换。例如,表达式hire_date > '01-JAN-90' 将导致字符串'01-JAN-90' 隐式转换为一个日期。因此,表达式中的VARCHAR2 或CHAR 值可以隐式转换为数字或日期数据类型。

    A,错误,需要视同to_date显示转换
    实验验证:
    首先确认默认的时间格式:
    sys@TEST0924> select sysdate from dual;

    SYSDATE
    ------------------
    17-OCT-13

    A,
    sh@TEST0924> SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category = 'post' AND promo_begin_date < '01-01-00';
    SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category = 'post' AND promo_begin_date < '01-01-00'
                                                                                                                         *
    ERROR at line 1:
    ORA-01843: not a valid month

    显示转换后:
    sh@TEST0924> SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category = 'post' AND promo_begin_date <to_date( '01-01-00','dd-mm-yy');

    PROMO_NAME                     PROMO_COST PROMO_BEGIN_DATE
    ------------------------------ ---------- ------------------
    post promotion #20-232                300 25-SEP-98
    post promotion #21-166               2000 25-SEP-98
    post promotion #20-449               4200 10-NOV-98


    B,
    sh@TEST0924> SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_cost LIKE 'post%' AND promo_begin_date < '01-01-2000';

    no rows selected
    C,
    sh@TEST0924> SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category LIKE 'P%' AND promo_begin_date < '1-JANUARY-00'
      2  ;

    no rows selected
    D,
    sh@TEST0924> SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category LIKE '%post%' AND promo_begin_date < '1-JAN-00';

    PROMO_NAME                     PROMO_COST PROMO_BEGIN_DATE
    ------------------------------ ---------- ------------------
    post promotion #20-232                300 25-SEP-98
    post promotion #21-166               2000 25-SEP-98
    post promotion #20-449               4200 10-NOV-98
  • 相关阅读:
    Mtk Ft6306 touch 驱动 .
    第一屏不显示懒加载的图片内容,这个方法可以搞定
    C#多线程中访问winform控件 (解决Winform 对象当前正在其他地方使用)
    变化的科技感十足的网站,推荐
    新年有感
    获取高精度时间注意事项 (QueryPerformanceCounter , QueryPerformanceFrequency)
    修改 TeamViewer ID 的方法
    VS2017离线安装包[百度云盘](收藏了)
    老子今天不加班,程序员也需要自由
    改变Eclipse 中代码字体大小
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13316915.html
Copyright © 2020-2023  润新知