stacking two tables

Database
Enthusiast

stacking two tables

I have two tables in same database like one is back book and one is new. Now i want to see data in one go- means i want to stack my both tables. Could you please help me in answering following questions

1. The name of columns are similar but the definition of few are not. So is it possible to stack these tables?

2. can i add new column to volatile table? for eg. alter table abc(volatile table) add column VARCHAR(100) null

3 REPLIES
Senior Apprentice

Re: stacking two tables

What do you mean by stack, probably a UNION ALL?

The first SELECT of a UNION determines the column names and datatypes, you can CAST a column to match the datatype of the 2nd table.

ALTER TABLE is not supported for Volatile Tables, you have to think before you create it :-)

Enthusiast

Re: stacking two tables

thanks dnoeth!

one thing more. i have two tables- but table 1 has two extra column. is it still possible to union the.

for eg; table 1- pol_cnl_typ,campaign_descrip,cnl_code

and table 2 -pol_cnl_typ

How can i union them. I do not want to alter my original table here as that will confuse other users.

Senior Apprentice

Re: stacking two tables

Simply add a CAST(NULL AS ...) using a matching datatype in the 2nd SELECT.