I have a table in Oracle, which has DATE
column. I can observe that SELECT DISTINCT
returns duplicates:
select distinct myDate from myTable;
myDate
----------------------------
2009-09-05 00:00:00
2009-09-05 00:00:00
But:
select distinct to_char(myDate, 'DD-MM-YYYY HH24:MI:SS') from myTable;
TO_CHAR(myDate,'DD-MM-YYYYHH24:MI:SS')
------------------------------------------------
05-09-2009 00:00:00
And next queries, which can tell more:
select count(*) from myTable;
COUNT(*)
----------
12
select myDate, count(*) from myTable group by myDate;
myDate COUNT(*)
---------------------------- ----------
2009-09-05 00:00:00 6
2009-09-05 00:00:00 6
select count(*) from myTable where myDate='2009-09-05';
COUNT(*)
----------
6
What can be the reason of such behaviour? As far as I know there is no more information stored in DATE
column which can make the difference (no time zone, no miliseconds).
EDIT: table DDL
Unfortunately I can't post whole DDL. Definition of the column is:
myDate DATE NOT NULL
What can be important, table is partitioned using this column:
PARTITION BY RANGE (myDate)
(
PARTITION P_19991231 VALUES LESS THAN
(TO_DATE('1999-12-31 00:00:00',
'YYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
);
There is more partitions in the table.
And also ENABLE ROW MOVEMENT
is ON.