SELECT * from T_a A where A.begintime=to_date (' 2013-1-1 ', ' yyyy-mm-dd ');
And
SELECT * from T_a A where To_char (a.begintime, ' yyyy-mm-dd ') = ' 2013-1-1 ';
The query results are the same.
The difference is that the processing steps of the query are not the same.
SELECT * from T_a A where A.begintime=to_date (' 2013-1-1 ', ' yyyy-mm-dd ');
is to first convert the string ' 2013-1-1 ' to a date format and then to compare it with the database.
If there are 1000 rows of data, then the operation is
1 characters converted to date, 1000 date comparison.
SELECT * from T_a A where To_char (a.begintime, ' yyyy-mm-dd ') = ' 2013-1-1 ';
is to convert the begintime of each row in the database into a character format and then compare it to the database.
If there are 1000 rows of data, then the operation is
1000 times the date is converted to characters, and 1000 string comparisons.
Ask
The second kind of general use under what circumstances ah, seems to affect the performance of the program AH
Chase Answer
So it is generally not recommended to use the second method ah.
Ask
There's always a reason why it's so used.
Transferred from: https://zhidao.baidu.com/question/528644264.html
Related to Oracle Database To_date () and To_char ()