Skip to main content

DDL Operations

Generate DDL statements from the context menu.

Access: Hover over table → Click Actions button (⋮) → SQL Templates

DDL Operations Menu

Available Operations

OperationWhat It DoesCost
CREATE TABLE (DDL)Generate full schema DDLFree
SELECTQuery templateQuery
INSERT INTOInsert templateQuery
COPY TABLECopy structure + dataQuery
CLONE TABLELightweight copy (metadata only)Free
TRUNCATEDelete all rows, keep schemaFree
ALTER OPTIONSModify table settingsFree
RENAMEChange table nameFree
DROPDelete tableFree

COPY vs CLONE

COPY: Duplicates data (slow, costs query charges)

CREATE TABLE `project.dataset.table_copy` AS
SELECT * FROM `project.dataset.table`

CLONE: Metadata-only, copy-on-write (instant, free)

CREATE TABLE `project.dataset.table_clone`
CLONE `project.dataset.table`

Use CLONE for backups, testing, staging environments.


Common Patterns

Backup with expiration:

CREATE TABLE `project.dataset.table_backup_20250110`
CLONE `project.dataset.table`
OPTIONS(expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 30 DAY))

Clone at specific time:

CREATE TABLE `project.dataset.table_clone`
CLONE `project.dataset.table`
FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)

Recover from TRUNCATE:

INSERT INTO `project.dataset.table`
SELECT * FROM `project.dataset.table`
FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)

ALTER OPTIONS

ALTER TABLE `project.dataset.table`
SET OPTIONS(
description = "Updated description",
expiration_timestamp = TIMESTAMP("2025-12-31"),
labels = [("env", "prod")],
max_time_travel_hours = 168
)

Permissions Required

  • CREATE: bigquery.tables.create
  • DROP: bigquery.tables.delete
  • ALTER: bigquery.tables.update

Information Schema Templates

Query INFORMATION_SCHEMA views directly from the context menu. Available under SQL Templates → Information Schema.

Tables

Right-click a table → SQL Templates → Information Schema.

TemplateWhat It Returns
Table ColumnsColumn names, types, modes, and descriptions
Column Field PathsFlattened paths for nested STRUCT/ARRAY fields
PartitionsPartition metadata including row counts and storage bytes
Table ConstraintsPrimary key and foreign key constraints
Table OptionsDescription, labels, expiration, and other table-level options

Datasets

Right-click a dataset → SQL Templates → Information Schema.

TemplateWhat It Returns
List TablesAll tables with type and creation time
List ColumnsAll columns across all tables in the dataset
Column Field PathsNested field paths for all tables
List ViewsViews with their SQL definitions
Materialized ViewsMaterialized views with refresh configuration
List RoutinesUser-defined functions and stored procedures
Table OptionsTable-level options across all tables
Table ConstraintsPK/FK constraints across all tables
Schema OptionsDataset-level options (description, labels, location)
Search IndexesSearch indexes defined on tables
Row Access PoliciesRow-level security policies

Projects

Right-click a project → SQL Templates → Information Schema.

TemplateWhat It Returns
Storage AnalysisPer-table costs (logical vs physical), billing model, compression ratio, usage check, time travel + fail-safe
Compute Cost AnalysisQuery patterns by cost, source detection (dbt/Dataform/Looker), edition, on-demand vs slot tier comparison
Slot Utilization TimelineReservation slot capacity usage over time
Failed QueriesRecent query errors with error messages
Partitioning & Clustering AuditTables that would benefit from partitioning or clustering
Top Expensive TablesTables ranked by combined query + storage cost