SQLite Forum

How to create a table as the union of two tables?
Login
I have two tables with the exact same columns (same order, same name, same data type)

I want to create a table as the union of these two tables.

I know I can show the result of the union with

```
SELECT * FROM tab1 UNION SELECT * FROM tab2;
```

But how to take the result into a new table?

This is what I came up with so far:

```
CREATE TABLE tempunion AS (SELECT * FROM tab1 WHERE 1=2);
INSERT INTO tempunion SELECT * FROM (SELECT * FROM tab1 UNION SELECT * FROM tab2);
```

Is there a better way to do this?