Oracle日期比较 to_char vs to_date

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

你可能感兴趣的:(Oracle日期比较 to_char vs to_date)