All Forums Analytics
saan 2 posts Joined 06/10
22 Jun 2010
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.

Adeel Chaudhry 773 posts Joined 04/08
22 Jun 2010

Please don't post same question multiple times.

-- If you are stuck at something .... consider it an opportunity to think anew.

You must sign in to leave a comment.