10

How do you save a postgresql query output as a table? Similar to the maketable query within Access. I want to be able to join other tables to the query output and making a new table would make life good. I am using Navicat to execute queries.

  • http://www.postgresql.org/docs/9.4/static/sql-selectinto.html – Vivek S. Mar 12 '15 at 06:36
  • possible duplicate of [SELECT .. INTO to create a table in PL/pgSQL](http://stackoverflow.com/questions/11979154/select-into-to-create-a-table-in-pl-pgsql) – Vivek S. Mar 12 '15 at 06:37

1 Answers1

15

If you have a select statement you can execute a CTAS

CREATE TABLE <table name> AS (
SELECT STATEMENT
)
Haleemur Ali
  • 26,718
  • 5
  • 61
  • 85