Reputation: 14472
How to create a new table and insert content of another table?
Upvotes: 3
Views: 56928
Reputation: 31
Like SQL Server you can create a temp table right from your select, the way is a little bit different.
Just execute:
temp_table = select 1 as col1, 'lorem ipsum' as col2 from dummy;
After that, you are able to use this temp table to query data from.
Like so:
select * from :temp_table;
Table Variable Type Definition
Unfortunately, there is some limitations using that. For example, you cannot simply insert new data. For that, exists some tricks.
Upvotes: 1
Reputation: 10396
Another, more SAP HANA specific solution is to use the
CREATE TABLE ... LIKE <TABLE_NAME> WITH [NO] DATA ...
This allows more control over the physical properties of the new table.
Upvotes: 3
Reputation: 14472
create column table my_new_table as
(select * from my_existing_table)
Upvotes: 13