Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have data with a timestamp field of the form '2014-01-01 00:00:00.99' in one of the columns. I want to create a new partition for the table every month. For this I did something like this.

CREATE TABLE t (id NUMBER , tstamp timestamp )
  PARTITION BY RANGE (tstamp)  (
    PARTITION t_jan_2009 VALUES LESS THAN (to_timestamp('2009-02-01 00:00:00.00','YYYY-MM-DD HH24:MI:SS.FF2')),
    PARTITION t_feb_2009 VALUES LESS THAN (to_timestamp('2009-03-01 00:00:00.00','YYYY-MM-DD HH24:MI:SS.FF2'))
);  

INSERT INTO t SELECT 1, '2009-02-10 12:34:45.56' from dual;

This is not the actual data but an equivalent sample. It gives the same error. SQL Error: ORA-01843: not a valid month

Why am I getting this error? Do I need to do something more?

share|improve this question
    
Check your date format. The default date format depends on NLS_TERRITORY & can be overriden by other settings, for example NLS_DATE_FORMAT. –  Phil Sumner Oct 13 '14 at 13:07

1 Answer 1

change to

insert into t select 1, to_timestamp ('2009-02-10 12:34:45.56','YYYY-MM-DD HH24:MI:SS.FF2') from dual;

should work. Don't rely on default formats.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.