Dynamic DDL

Analytics
Fan

Dynamic DDL

Hi,
I need to create a new table based on the data from a query result. The name of the columns in new table will be the data values from result of a query.

For example, lets say my source query returns following records:

Field1 Field2
V1 A1
V2 A2
V3 A3

Then table DDL should be like:

Create table testdb.test_tab
(
Start_dt date,
v1 varchar(30),
v2 varchar(30),
v3 varchar(30),
a1 varchar(30),
a2 varchar(30),
a3 varchar(30)
)
primary index(start_dt);

Currently I am thinking about exporting query result to a file, and append to a file with create table statement, then execute. I am not sure if this will work, have not try it yet.
Please share your ideas/work.

Appreciate you time, thank you.
Tags (2)
1 REPLY
Teradata Employee

Re: Dynamic DDL

Please don't post same question multiple times.