-- Created on savesnippets.com · https://savesnippets.com/qX4o0M6WKMF779 -- Copy archived users into a separate table INSERT INTO users_archive (id, name, email, archived_at) SELECT id, name, email, NOW() FROM users WHERE status = 'archived'; -- Bulk-insert with literal values INSERT INTO regions (code, name) VALUES ('NA', 'North America'), ('EU', 'Europe'), ('AP', 'Asia Pacific'); -- "Materialize" the result of an expensive query into a new table CREATE TABLE top_users AS SELECT user_id, SUM(amount) AS total FROM orders GROUP BY user_id ORDER BY total DESC LIMIT 1000; -- PostgreSQL — CREATE TABLE LIKE for the schema, then INSERT CREATE TABLE orders_2024 (LIKE orders INCLUDING ALL); INSERT INTO orders_2024 SELECT * FROM orders WHERE created_at >= '2024-01-01' AND created_at < '2025-01-01';