Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I need to partition an existing table which is main.customer by year. The situation I have is that, I have a column that contains a string with year in it and I want to extract the year part from that string.

my sample query is..

CREATE TABLE main.customer_prtn (LIKE main.customer)
PARTITION BY RANGE (to_date(substring(ref_id,1,4),'YYYY'))
(START (date '2008') INCLUSIVE,
....
END (date '2015') EXCLUSIVE
EVERY (INTERVAL '1 year') );

When I run the query, i get the message

ERROR:  syntax error at or near "("
LINE 2: PARTITION BY RANGE (to_date(substring(ref_id,1,4),'YYYY'))
share|improve this question
    
You really should clarify your question! – Peter yesterday

PostgreSQL doesn't have declarative partitioning yet (a patch for v10 is under review).

Read the documentation about partitioning to find out how it has to be done currently.

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.