Tuesday, December 07, 2010

Using Teradata's CURRENT_TIMESTAMP(n)

CURRENT_TIMESTAMP can take an argument stating the precision. This allows the result to easily be passed to a column with matching precision.

CREATE MULTISET TABLE test1,
    
NO FALLBACK,
    
NO BEFORE JOURNAL,
    
NO AFTER JOURNAL (
    
id          INT           NOT NULL,
    
start_dtm0  TIMESTAMP(0)  NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
    
start_dtm1  TIMESTAMP(1)  NOT NULL DEFAULT CURRENT_TIMESTAMP(1),
    
start_dtm2  TIMESTAMP(2)  NOT NULL DEFAULT CURRENT_TIMESTAMP(2),
    
start_dtm3  TIMESTAMP(3)  NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    
start_dtm4  TIMESTAMP(4)  NOT NULL DEFAULT CURRENT_TIMESTAMP(4),
    
start_dtm5  TIMESTAMP(5)  NOT NULL DEFAULT CURRENT_TIMESTAMP(5),
    
start_dtm6  TIMESTAMP(6)  NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
);


Results:

Column Value
start_dtm0 12/07/2010 3:10:30
start_dtm1 12/07/2010 3:10:30.8
start_dtm2 12/07/2010 3:10:30.82
start_dtm3 12/07/2010 3:10:30.820
start_dtm4 12/07/2010 3:10:30.8200
start_dtm5 12/07/2010 3:10:30.82000
start_dtm6 12/07/2010 3:10:30.820000

Does Teradata Support BIT Columns? Yes and No.

In Teradata 13.0, I can create a column with a type of bit.

CREATE MULTISET TABLE test1,
    
NO FALLBACK,
    
NO BEFORE JOURNAL,
    
NO AFTER JOURNAL 

(
    
id         INT  NOT NULL,
    
bitColumn  bit

);

But did it really create a bit column? No.

Query

SELECT RequestText
FROM DBC.Tables
WHERE DatabaseName = 'rgarrison'
  
AND TableName    = 'test1';


Result

CREATE MULTISET TABLE test1,
    NO FALLBACK,
    NO BEFORE JOURNAL,
    NO AFTER JOURNAL
(
    id INT NOT NULL,
    bitColumn BYTEINT FORMAT '9'
);

Query

SELECT ColumnType, ColumnLength
FROM DBC.Columns
WHERE DatabaseName = 'rgarrison'
  
AND TableName    = 'test1'
  
AND ColumnName   = 'bitColumn';


Result

ColumnType ColumnLength
I1 1

So, Teradata will allow you to specify bit as a datatype, but it will silently translate that request to byteint.

Tuesday, November 16, 2010

First Teradata-Related Article is Live

My first article has gone live here: Exploring Teradata 13's PERIOD Data Type.

I am very excited to be writing in this new role. A follow-up article should be up within two weeks.

Tuesday, November 02, 2010

First Teradata-Related Article

I just sent the draft of my first Teradata-related article to the publisher.

It will be published on Teradata Developer Exchange. The title of the article is "Exploring Teradata 13's PERIOD Data Type". It is the first of at least two parts. The second part, on PERIOD functions in 13, should publish fairly closely behind the first.

I am very excited to be writing in my new role. There is so much to learn about data warehousing and business intelligence. I am just scratching at the surface.