How to create a table in my data lab?

Teradata Studio
Enthusiast

How to create a table in my data lab?

hi, so i exported 3 similar CSV files from my sharedrive to my data lab in Teradata.after exporting all 3 csv files to my data lab, i merged the three files using a union function

 

select "column1","column2","column3" from "datalab"." table1"

union

select "column1","column2","column3" from "datalab"." table2"

union

select "column1","column2","column3" from "datalab"." table3";

 

now i like to create that table and insert it into my data lab and call that table "COMBINED TABLE".

 

How do i create or insert that table in my data lab? my data lab is called "datalab"

Thanks

 

1 REPLY 1
Teradata Employee

Re: How to create a table in my data lab?

Several options.

Step by step:

CREATE TABLE datalab.COMBINED_TABLE ...;
insert INTO datalab.COMBINED_TABLE (col1, col2, col3) select "column1","column2","column3" from "datalab"." table1";
insert INTO datalab.COMBINED_TABLE (col1, col2, col3) select "column1","column2","column3" from "datalab"." table2";
insert INTO datalab.COMBINED_TABLE (col1, col2, col3) select "column1","column2","column3" from "datalab"." table3";

Using your UNION query for the insert:

 

CREATE TABLE datalab.COMBINED_TABLE ...;
insert INTO datalab.COMBINED_TABLE (col1, col2, col3) 
SELECT * FROM
(select "column1","column2","column3" from "datalab"." table1"
union
select "column1","column2","column3" from "datalab"." table2"
union
select "column1","column2","column3" from "datalab"." table3"
) as DerivedTable;

Using your UNION query to both define and insert:

CREATE TABLE datalab.COMBINED_TABLE AS (
select "column1","column2","column3" from "datalab"." table1"
union
select "column1","column2","column3" from "datalab"." table2"
union
select "column1","column2","column3" from "datalab"." table3"
) WITH DATA 
<add a PRIMARY INDEX clause here>;