您的当前位置:首页Oracle日期比较 to_char vs to_date

Oracle日期比较 to_char vs to_date

2024-12-12 来源:哗拓教育

日期比较应该使用哪个函数,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

显示全文