https://asktom.oracle.com/pls/asktom/f%3Fp%3D100:11:0::::P11_QUESTION_ID:4843459400346642911
日期比較應該使用哪個函數,to_char
還是to_date
?
date_column >= to_date('2016-01-19', 'YYYY-MM-DD')
to_char(date_column, 'YYYY-MM-DD') <= '2016-01-19'
Do you want to convert EVERY ROW from a date to string to compare?
Also, using to_char() on the database date column would typically **obviate the use of any indexes **
to_char
不僅要將每一行的值轉成字符串,還會丟棄索引。
總是使用to_date
。