user3848207
user3848207

Reputation: 4927

Create temporary table from view

I am using sqlite3.

Suppose I have a view view_intermediate. I would like to create a temporary table from this view. In other words, turn the result of the view into a temporary table.

How should the SQL statement look like to do this?

Upvotes: 1

Views: 126

Answers (1)

Barry Piccinni
Barry Piccinni

Reputation: 1801

SQLite supports CREATE TABLE AS..SELECT, so assuming you want the data in the table:

CREATE TABLE myTable AS
SELECT *
FROM view_intermediate;

If you want a table to be created from the view, but don't want the data, you can add a false condition.

CREATE TABLE myTable AS
SELECT *
FROM view_intermediate
WHERE 1=2;

Upvotes: 4

Related Questions