SnowDDL
  • 👋Introduction
  • 🚩Getting started
  • 📋Main features
  • 🪤SnowDDL vs. Declarative DCM
  • In-depth guides
    • 👓Object identifiers
    • 📐Data types
    • 📦Object types
    • 🎭Role hierarchy
    • 🚧Permission model
    • 🔦Other guides
      • Administration user
      • Integrations
      • Inbound shares
      • Object OWNERSHIP
      • Safe & unsafe DDL
      • Dependency management
      • Short hash explained
      • Env Prefix explained
      • Team workflow
      • Limitations & workarounds
      • Fivetran
      • Airbyte
      • Encrypt user passwords
      • Iceberg Tables
  • Basic usage (CLI + YAML)
    • 💻CLI interface
    • 📦YAML configs
      • ACCOUNT PARAMETER
      • ACCOUNT POLICY
      • AGGREGATION POLICY
      • ALERT
      • AUTHENTICATION POLICY
      • BUSINESS ROLE
      • DATABASE
      • DYNAMIC TABLE
      • EVENT TABLE
      • EXTERNAL ACCESS INTEGRATION
      • EXTERNAL FUNCTION
      • EXTERNAL TABLE
      • FILE FORMAT
      • FUNCTION
      • HYBRID TABLE
      • ICEBERG TABLE
      • MASKING POLICY
      • MATERIALIZED VIEW
      • NETWORK POLICY
      • NETWORK RULE
      • PERMISSION MODEL
      • PIPE
      • PLACEHOLDER
      • PROCEDURE
      • PROJECTION POLICY
      • RESOURCE MONITOR
      • ROW ACCESS POLICY
      • SCHEMA
      • SECRET
      • SEQUENCE
      • SHARE (outbound)
      • STAGE
      • STAGE FILE
      • STREAM
      • TABLE
      • TASK
      • TECHNICAL ROLE
      • USER
      • VIEW
      • WAREHOUSE
    • 🏷️YAML placeholders
    • 📬YAML tag !include
    • 🔐YAML tag !decrypt
  • Single DB
    • 🦀Overview
  • Advanced usage (Python)
    • ⚙️Programmatic config
    • 🐍Architecture overview
      • 🔵Blueprints
      • 🟣Config
      • 🟠Parsers
      • 🟢Resolvers
      • 🔴Engine
    • 🏗️Query builder & formatter
  • Breaking changes log
    • 0.45.0 - March 2025
    • 0.41.0 - January 2025
    • 0.37.0 - December 2024
    • 0.36.0 - November 2024
    • 0.33.0 - October 2024
    • 0.27.0 - May 2024
  • Links
    • GitHub repository
    • PyPI package
    • YouTube tutorials
    • Changelog
    • LinkedIn profile
Powered by GitBook
On this page
  • Schema
  • Policy reference parameters
  • Usage notes
  • Safe & unsafe operations
  • Links
  1. Basic usage (CLI + YAML)
  2. YAML configs

TABLE

Config path: /<database>/<schema>/table/<name>.yaml

Example:

columns:
  actor_id: NUMBER(10,0) NOT NULL
  first_name: VARCHAR(45) NOT NULL
  last_name: VARCHAR(45) NOT NULL
  last_update: TIMESTAMP_NTZ(3)

primary_key: [actor_id]
columns:
  ticket_no:
    type: VARCHAR(13) NOT NULL
    comment: "Ticket number"

  flight_id:
    type: NUMBER(10,0) NOT NULL
    comment: "Flight ID"

  boarding_no:
    type: NUMBER(10,0) NOT NULL
    comment: "Boarding pass number"

  seat_no:
    type: VARCHAR(4) NOT NULL
    comment: "Seat number"

primary_key: [ticket_no, flight_id]

unique_keys:
  - [flight_id, boarding_no]
  - [flight_id, seat_no]

foreign_keys:
  - columns: [ticket_no, flight_id]
    ref_table: ticket_flights
    ref_columns: [ticket_no, flight_id]

Schema

  • columns (dict)

    • {key} (ident) - column name

    • {value} (dict)

      • default (str) - default SQL expression

      • default_sequence (ident) - sequence used for "auto increment"

      • comment (str)

  • is_transient (bool) - make table TRANSIENT

  • retention_time (int) - data retention time in days

  • cluster_by (list)

    • {items} (str) - SQL expressions for CLUSTER BY

  • change_tracking (bool) - enable CHANGE TRACKING

  • search_optimization (bool) - enable SEARCH OPTIMIZATION on the whole table --- OR ---

  • search_optimization (dict) - enable SEARCH OPTIMIZATION on specific columns

    • {key} (str) - search optimization method (e.g. EQUALITY, SUBSTRING, GEO);

    • {value} (list)

      • {items} (str) - search optimization targets (column names and VARIANT column paths)

  • comment (str)

  • primary_key (list)

    • {items} (ident) - column names for PRIMARY KEY constraint

  • unique_keys (list)

    • {items} (list)

      • {items} (ident) - column names for UNIQUE KEY constraint

  • foreign_keys (list)

    • {items} (dict) - FOREIGN KEY definitions

      • columns (list)

        • {items} (ident) - column names from current table

      • ref_table (ident) - reference table

      • ref_columns (list)

        • {items} (ident) - column names from reference table

Policy reference parameters

  • aggregation_policy (dict)

    • columns (list)

      • {items} (ident) - optional reference column names defining "entity"

  • masking_policies (list)

    • {items} (dict)

      • columns (list)

        • {items} (ident) - reference column names

  • projection_policies (list)

    • {items} (dict)

      • column (ident) - reference column name

  • row_access_policy (dict)

    • columns (list)

      • {items} (ident) - reference column names

Usage notes

  1. Columns definition has two possible syntax options:

    a) Short syntax (str) with column type definition only. b) Full syntax (dict) with type definition as well as other properties.

  2. Column default is an SQL expression, not value. VARCHAR values should be enclosed in quotes. TIMESTAMP_* values should be casted explicitly.

Safe & unsafe operations

The following operations on tables are considered as "safe":

  • Create a new table from scratch;

  • Add a new column to the end of existing table;

  • Change comment on table;

  • Change comment on specific column;

All other operations are "unsafe".

Additionally, in order to execute CREATE OR REPLACE TABLE ... AS SELECT , the following CLI option must be specified: --apply-replace-table

Links

PreviousSTREAMNextTASK

Last updated 7 months ago

{value} (str) - full with optional "NOT NULL" constraint --- OR ---

type (str) - full with optional "NOT NULL" constraint

collate (str) - column for string comparison

policy_name (ident) - name of

policy_name (ident) - name of

policy_name (ident) - name of

policy_name (ident) - name of

Column type is a full native Snowflake data type definition, exactly how it appears in output of command. Aliases and short forms .

Anonymous auto-increment is not supported. All must be created explicitly and assigned to default_sequence of relevant table columns. It helps to preserve sequence value when table is re-created to apply changes which cannot be applied via ALTER TABLE.

is_transient and retention_time are inherited from parent and objects if omitted.

Currently only standard column names are supported for . Paths for VARIANT columns are not supported due to high complexity of parsing the output of DESC SEARCH OPTIMIZATION ON ... command. We expect it to be improved in future, once this features leaves the "Public preview" status.

📦
data type
data type
collation
AGGREGATION POLICY
MASKING POLICY
PROJECTION POLICY
ROW ACCESS POLICY
DESC TABLE
are not allowed
sequences
SCHEMA
DATABASE
SEARCH OPTIMIZATION on specific columns
CREATE TABLE
ALTER TABLE
ALTER TABLE ... ALTER COLUMN
SHOW TABLE
DESC TABLE
Parser & JSON Schema (GitHub)