CREATE TABLE AS
Create a new table from the result of a query.
Syntax
Parameters
| Parameter | Description |
|---|---|
| table_name | Name of the table to create |
| select_statement | A SELECT query whose result set defines the columns and rows of the new table |
Examples
Create from a SELECT
CREATE TABLE top_articles AS
SELECT id, title, views
FROM articles
ORDER BY views DESC
LIMIT 100;
Create from a filtered query
CREATE TABLE engineering_articles AS
SELECT id, title, body, published_at
FROM articles
WHERE category = 'engineering' AND views > 1000;