Lessons › SQL › Deep Dive: Database Admin & ETL
SQL lesson
CREATE TABLE AS SELECT
CREATE TABLE AS SELECT builds a brand-new, permanent table by running a query and saving whatever it returns - filtered, joined, or reshaped however you need. Like photocopying a document before scribbling notes on it, the original stays untouched while you work freely on the copy.
Try this lesson free →Example
Creating a Safe Working Copy with CREATE TABLE AS SELECT
CREATE TABLE orders_clean AS
SELECT * FROM ordersStep by step
- CREATE TABLE defines a new table along with its columns.
CREATE TABLE orders_clean AS - The asterisk symbol means all columns.
CREATE TABLE orders_clean AS SELECT * - FROM tells SQL which table to pull the data from.
CREATE TABLE orders_clean AS SELECT * FROM orders;
Practice
1. Write a query that creates a new table called products_clean by copying all data from the products table.
CREATE TABLE products_clean AS SELECT * FROM products2. Write a query that creates a new table called customers_clean by copying all data from the customers table.
CREATE TABLE customers_clean AS SELECT * FROM customers3. Write a query that creates a new table called orders_clean by copying all data from the orders table.
CREATE TABLE orders_clean AS SELECT * FROM orders4. Write a query that creates a new table called inventory_clean by copying all data from the inventory table.
CREATE TABLE inventory_clean AS SELECT * FROM inventory5. Write a query that creates a new table called suppliers_clean by copying all data from the suppliers table.
CREATE TABLE suppliers_clean AS SELECT * FROM suppliersLearn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.
Try this lesson free →