您好,登錄后才能下訂單哦!
通過(guò)一道051的考題看這兩個(gè)默認(rèn)參數(shù)的用法:
91.View the Exhibit and examine the structure of the PROMOTIONS table. Which two SQL statements would execute successfully?
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'));
答案:AB
A:正確
B:正確
C:錯(cuò)誤
D:錯(cuò)誤
C和D的錯(cuò)誤都是因?yàn)闆](méi)有指定轉(zhuǎn)換的格式,而默認(rèn)的格式是通過(guò)
NLS_DATE_LANGUAGEE和NLS_DATE_FORMAT決定的,因此他們都存在問(wèn)題,可以進(jìn)行如下修改
SQL> select TO_DATE(SUBSTR('01-JAN-2000',8)) from dual; select TO_DATE(SUBSTR('01-JAN-2000',8)) from dual ORA-01861: 文字與格式字符串不匹配 SQL> alter session set NLS_DATE_FORMAT='yyyy'; Session altered SQL> select TO_DATE(SUBSTR('01-JAN-2000',8)) from dual; TO_DATE(SUBSTR('01-JAN-2000',8 ------------------------------ 2000/12/1 SQL> select TO_DATE('JUN 01 98') from dual; select TO_DATE('JUN 01 98') from dual ORA-01841: (完整) 年份值必須介于 -4713 和 +9999 之間, 且不為 0 SQL> alter session set NLS_DATE_FORMAT='MON DD RR'; Session altered SQL> alter SESSION SET NLS_DATE_LANGUAGE='AMERICAN'; Session altered SQL> select TO_DATE('JUN 01 98') from dual; TO_DATE('JUN0198') ------------------ 1998/6/1
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。