CREATE TABLE creates a new permanent table in a BigQuery dataset with user-defined schema, partitioning, clustering, options, and optional CTAS.
CREATE TABLE persists structured data inside a dataset so teams can query, share, secure, and optimize it. Use it when you need a reusable table instead of an ad-hoc query result.
BigQuery supports four patterns: CREATE TABLE
, CREATE TABLE IF NOT EXISTS
, CREATE OR REPLACE TABLE
, and CREATE TABLE AS SELECT
(CTAS). Each pattern accepts column definitions, partitioning, clustering, table OPTIONS, and labels.
List each column followed by a data type and optional NOT NULL
or OPTIONS(description="…")
. Common types include INT64, NUMERIC, STRING, BOOL, BYTES, DATE, DATETIME, TIMESTAMP, JSON, and ARRAY.
Add PARTITION BY
with a date/timestamp column or expression. Example: PARTITION BY DATE(order_date)
splits Orders
by day, reducing scanned data on time-filtered queries.
Append CLUSTER BY
and up to four high-cardinality columns used in equality predicates. For Orders
, CLUSTER BY customer_id
speeds customer-specific lookups.
CTAS materializes a query and creates the table in one step—ideal for snapshots, backfills, or denormalized reporting tables.
Always qualify the dataset, use descriptive names, document columns with OPTIONS(description=)
, partition before loading data, and apply least-privilege roles like bigquery.dataEditor
only where needed.
The example below creates a partitioned, clustered Orders
table with labels and a description in an idempotent way.
You can convert an unpartitioned table to a partitioned one with CREATE TABLE new_table PARTITION BY … AS SELECT * FROM old_table
, then swap names. Direct ALTER isn’t supported.
Yes. Replacing a table preserves ACLs, metadata, and labels, so downstream jobs keep working.