ocp考试资料群:569933648 验证码:ocp OCP 12c 19c考试题库解析与资料群:钉钉群号:35277291
全部博文(487)
分类: Oracle
2019-02-28 11:35:19
47、(10-6)choose two
You need to calculate the number of days from 1st January 2007 till date.
Dates are stored in the default format of dd-mon-rr.
Which two SQL statements would give the required output?
A) SELECT TO_DATE (SYSDATE, 'DD/MONTH/YYYY') - '01/JANUARY/2007' FROM DUAL;
B) SELECT SYSDATE - TO_DATE ('01/JANUARY/2007') FROM DUAL;
C) SELECT SYSDATE -'01-JAN-2007' FROM DUAL;
D) SELECT SYSDATE - TO_DATE ('01-JANUARY-2007') FROM DUAL;
E) SELECT TO_CHAR (SYSDATE, 'DD-MOM-YYYY') - '01-JAN-2007' FROM DUAL;
Answer:BD
(解析:对数据进行混合运算时必须要用转换函数转换为日期格式,因为它不会隐式转换,但是我们在insert
数据时,会实现隐式转换。
SQL> SELECT SYSDATE - TO_DATE ('01-1 月-2007') FROM DUAL;
或者:
SQL> SELECT SYSDATE - TO_DATE ('01/1 月/2007') FROM DUAL;
)