Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 13 May 2009 @ 09:34:42 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: Columns Part of Partitioning Expression
 
From:   Curley, David

Following up on Geoffrey Rommel's point, you might want to consider not storing your months as yyyymm but as actual dates, either the first or last day of the month. That makes it easier to do relative operations in SQL using functions like add_months. I tend to prefer using the first day of the month, since I don't like how Teradata handles the last day of the month in add_months, but that's just me.

To be fair, choosing between yyyymm and a date is often six of one, half dozen of the other - you end up having to convert one to other a fair amount anyway.

If you use dates, you can change the partition clause to

     Partition by range_n(column1_date between '2006/12/01' and '2007/12/01'
     each interval '1' month)

(Or use the 31st if that's what you prefer.)

Since dates are integers under the covers, there's no space impact to using them over an integer field (although you will save space if you use Geoffrey's (year - 1990) * 12 + month trick to store it as a smallint).


Dave



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023