Select into temp table in PostgreSQL? [duplicate] Select into temp table in PostgreSQL? [duplicate] sql sql

Select into temp table in PostgreSQL? [duplicate]


You can try to use Create Table As command like this:

CREATE TEMP TABLE mytable ASSELECT * from source_tab;

From the docs:

This command is functionally similar to SELECT INTO, but it is preferred since it is less likely to be confused with other uses of the SELECT INTO syntax. Furthermore, CREATE TABLE AS offers a superset of the functionality offered by SELECT INTO.

The CREATE TABLE AS command allows the user to explicitly specify whether OIDs should be included. If the presence of OIDs is not explicitly specified, the default_with_oids configuration variable is used.