This topic is the test time format, the date of the storage format, within the Oracle is composed of the following seven parts: Century, year, month, day, hour, minute, second.
OK, let's do a test:
Gyj@ocm> CREATE TABLE Gyj_order (order_id int,order_date date);
Table created.
gyj@ocm> INSERT into Gyj_order values (1,sysdate);
1 row created.
Gyj@ocm> commit;
Commit complete.
Gyj@ocm> SELECT * from Gyj_order where order_date> to_date (' June 2006 ', ' MON ddyyyy ');
Order_idorder_dat
---------- ---------
116-jul-13
Explain answer a is correct
Gyj@ocm> SELECT * from Gyj_order whereto_char (order_date, ' MON DD YYYY ') = ' June 16 2013 ';
Order_idorder_dat
---------- ---------
116-jul-13
Explain the answer b is correct
Gyj@ocm> Select To_char (add_months (sysdate,6), ' mondd YYYY ') from dual;
To_char (Add_mo
--------------
16 2014.
Gyj@ocm> SELECT * from Gyj_order whereorder_date> to_char (add_months (sysdate,6), ' MON DD YYYY ');
SELECT * from Gyj_order where Order_date>to_char (Add_months (sysdate,6), ' MON DD YYYY ')
*
ERROR at line 1:
Ora-01858:a non-numeric character is found where Anumeric was expected
EXPLANATION The answer c is incorrect, the time type and the character type cannot be compared
Gyj@ocm> SELECT * from Gyj_order where Order_datein (To_date (' 2013 ', ' MON dd YYYY '), To_char (' June 2013 ', ' MON DD YYYY '));
SELECT * from Gyj_order where Order_datein (To_date (' 2013 ', ' MON dd YYYY '), To_char (' June 2013 ', ' MON dd YYYY '))
*
ERROR at line 1:
Ora-01722:invalid number
Gyj@ocm> Select To_char (' 2013 ', ' MON ddyyyy ') from dual; Select To_char (' June 2013 ', ' MON DD YYYY ') from dual
*
ERROR at line 1:
Ora-01722:invalid number
The above writing is wrong, already is the character does not need to use the TO_CHAR transformation, looks the following writing is correct:
Gyj@ocm> Select To_char (to_date (' 2013 ', ' mondd YYYY '), ' MON DD YYYY ') from dual;
To_char (to_
-----------
April 16 2013
There are also time and character types can not be directly calculated, the following error:
Gyj@ocm> SELECT * from Gyj_order where Order_datein (To_char (To_date (' June 2013 ', ' MON dd YYYY '), ' MON dd YYYY '));
SELECT * from Gyj_order where Order_datein (To_char (To_date (' 2013 ', ' MON dd YYYY '), ' MON dd YYYY '))
*
ERROR at line 1:
Ora-01858:a non-numeric character is found where Anumeric was expected
Answer d is not correct
Final correct answer selected: AB
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/