SQL Dialects Reference/Write queries/Save results from select query as new table

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Save results from select query as new table[edit | edit source]

Problem: save results from an arbitrary SELECT query (SELECT columns FROM table ...) as a new permanent table new_table.

Standard ?
DB2 ?
Firebird ?
Ingres ?
Linter CREATE TABLE new_table AS SELECT columns FROM table ...
MonetDB CREATE TABLE new_table AS SELECT columns FROM table ... WITH DATA
MSSQL SELECT columns INTO new_table FROM table ...
MySQL CREATE TABLE new_table [AS] SELECT columns FROM table ...
Oracle CREATE TABLE new_table [AS] SELECT columns FROM table ...
PostgreSQL
  • SELECT columns INTO new_table FROM table ...
  • CREATE TABLE new_table [AS] SELECT columns FROM table ...
SQLite CREATE TABLE new_table [AS] SELECT columns FROM table ...
Virtuoso CREATE TABLE new_table [AS] SELECT columns FROM table ...