Create temporary table

Database
N/A

Create temporary table

I need to create a temporary table using as source a portion of another table from my TeraData DataBase.
The temporary table must have the same definition of the source table.

I know what the syntaxe would be like in SQLServer:
"Select top 10 * into TempTable from SourceTable"

But when I try this in TeraData I get the error message:
Syntaxe error: INTO clause is not allowed.

Can anybody help me to solve this problem or find another way to do the trick?

Thanks in advance.
Rodrigo.
4 REPLIES

Re: Create temporary table

Try INSERT INTO TempTable SELECT TOP 10 * FROM SourceTable if TempTable is created beforehand.

Try CREATE TABLE AS... syntax if not.

HTH

Cheers.

Carlos.
N/A

Re: Create temporary table

Never mind answering, guys, I have already found out how to do what I need.

Just to register here the solution I came up with (and hopefully help anyone who eventualy stumbles in this issue):
"CREATE TABLE tempTable AS (select top 10 * FROM sourceTable) WITH data;

Note: The version 12 of TeraData does not support this construction for sourceTables containing Identity Columns =/ I hope they fix that for newer versions...

Regards.
Rodrigo.
N/A

Re: Create temporary table

Hehehe that is just what I did, Carlos!

Thanks, anyway.
;)

Rodrigo.

Re: Create temporary table

For others who are used to using temp tables at the session level only , I have added the missing qualifier.

CREATE Volatile TABLE tempTable AS (select top 10 * FROM sourceTable) WITH data;