Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teradata Volatile Table Statement is not creating any rows

Tags:

teradata

I want to create table in Teradata. Therefore I am using this syntax:

    CREATE VOLATILE TABLE a AS
    (
        Select * FROM ...
    ) WITH DATA PRIMARY INDEX ( ACCOUNT_ID )
;

The inner SELECT statement results in 4 rows. However, when I run the entire query, the resulting data set does not have any rows. Strange, I know - that`s why I'm writing. Please help. Thanks.

like image 414
Adam Avatar asked Jun 14 '13 15:06

Adam


People also ask

How do I create a volatile table in Teradata with data?

CREATE VOLATILE TABLE GEEK ( ROLLNO INT, FIRST_NAME VARCHAR(15), LAST_NAME VARCHAR(15) ) PRIMARY INDEX (ROLLNO) ON COMMIT PRESERVE ROWS; Here, you can clearly see the last line written as ON COMMIT PRESERVE ROWS this line will preserve the data after inserting it by you. The default value is ON COMMIT DELETE ROWS.

Which option should be chosen while creating volatile table?

Syntax: /* Volatile Table Syntax - Teradata */ CREATE VOLATILE TABLE table_1.

What is on commit preserve rows in Teradata?

The ON COMMIT PRESERVE ROWS option provides the more normal situation where the table rows are kept after the end of the transaction. If the rows are going to be needed for other queries in other transactions.

Can we create index on volatile table in Teradata?

Can I create a secondary index on a volatile table? This is possible when the table is created. Thus, you cannot first create the table and then execute a CREATE INDEX statement.


Video Answer


1 Answers

You need to include the ON COMMIT PRESERVE ROWS option with your DDL for the volatile table:

   CREATE VOLATILE TABLE a AS
    (
        Select * FROM ...
    ) WITH DATA 
    PRIMARY INDEX ( ACCOUNT_ID )
    ON COMMIT PRESERVE ROWS;

The default COMMIT mode for volatile (and global temporary) tables is to DELETE the rows at the end of the transaction.

like image 120
Rob Paller Avatar answered Sep 20 '22 03:09

Rob Paller