CREATE TABLE AS (CTAS)
CREATE TABLE AS (CTAS) is a SQL statement in the DDL Statements category. CTAS creates a new table and populates it with query results in one atomic operation. The syntax is CREATE TABLE new_table AS SELECT * FROM source_table;. It returns new table created. A typical example: -- Simple copy: CREATE TABLE employees_backup AS SELECT * FROM employees; -- Filtered copy: CREATE TABLE it_employees AS SELECT * FROM employees WHERE department = 'IT'; -- With transformations: CREATE TABLE sales_summary AS SELECT product_id, SUM(amount) AS total_sales, COUNT(*) AS order_count FROM orders GROUP BY product_id; -- PostgreSQL: includes data and column types but NOT indexes or constraints CREATE TABLE emp_archive AS SELECT * FROM employees WHERE hire_date < '2020-01-01'… A close relative is CREATE TABLE, which creates a new table in the database with specified columns, data types, and constraints. A close relative is ALTER TABLE, which modifies an existing table: add/drop columns, modify data types, rename, add/drop constraints.