ALTER ICEBERG TABLE

statementpartialIceberg & external tables

docs.snowflake.com ↗

Object: ICEBERG TABLE

Modifies properties such as clustering options and tags for an existing Apache Iceberg™ table. Note To replace the catalog integration for an externally managed Iceberg table in a standard Snowflake database with a different catalog integration, see SYSTEM$SET_CATALOG_INTEGRATION. You can also use an ALTER ICEBERG TABLE statement to refresh or convert a table, optimize a table to clear active position-delete references for live data files, alter a structured type column, evolve partition specs, or manage version tags. The syntax for those operations varies considerably. To view the syntax, parameter descriptions, usage notes, and examples for these operations, see the following pages: - ALTER ICEBERG TABLE … REFRESH - ALTER ICEBERG TABLE … CONVERT TO MANAGED - ALTER ICEBERG TABLE … OPTIMIZE - ALTER ICEBERG TABLE … ALTER COLUMN … SET DATA TYPE (structured types) - ALTER ICEBERG TABLE … ADD | DROP | REPLACE PARTITION BY - ALTER ICEBERG TABLE … VERSION_TAG This topic refers to Iceberg tables as simply “tables” except where specifying Iceberg tables avoids confusion.

Syntax

supportedpartialnot supportednot scored

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> { clusteringAction | tableColumnAction }

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> RENAME TO <new_table_name>

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> SET
  [ REPLACE_INVALID_CHARACTERS = { TRUE | FALSE } ]
  [ CATALOG_SYNC = '<snowflake_open_catalog_integration_name>']
  [ DATA_RETENTION_TIME_IN_DAYS = <integer> ]
  [ AUTO_REFRESH = { TRUE | FALSE } ]
  [ TARGET_FILE_SIZE = { AUTO | 16MB | 32MB | 64MB | 128MB } ]
  [ PATH_LAYOUT = { FLAT | HIERARCHICAL } ]
  [ STORAGE_SERIALIZATION_POLICY = { COMPATIBLE | OPTIMIZED } ]
  [ CONTACT ( <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ] ) ]
  [ LOG_EVENT_LEVEL = { ERROR | WARN | INFO | DEBUG } ]
  [ ERROR_LOGGING = { TRUE | FALSE } ]
  [ ENABLE_DATA_COMPACTION = { TRUE | FALSE } ]
  [ ICEBERG_MERGE_ON_READ_BEHAVIOR = { 'AUTO' | 'ENABLED' | 'DISABLED' } ]
  [ ENABLE_ICEBERG_MERGE_ON_READ = { TRUE | FALSE } ]
  [ TABLE_PROPERTIES = ( '<key>' = '<value>' [ , '<key>' = '<value>' , ... ] ) ]
  [ ENABLE_SCHEMA_EVOLUTION = { TRUE | FALSE } ]
  [ MATCH_BY_COLUMN_NAME = { CASE_INSENSITIVE | CASE_SENSITIVE } ]
  [ ALLOW_V3_EXPRESSION_DEFAULTS = { TRUE | FALSE } ]
  [ TIME_TRAVEL_TIMESTAMP_SOURCE = { 'SNOWFLAKE_METADATA' | 'ICEBERG_METADATA' } ]

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> UNSET
  [ REPLACE_INVALID_CHARACTERS ]
  [ PATH_LAYOUT ]
  [ LOG_EVENT_LEVEL ]
  [ ERROR_LOGGING ]
  [ ENABLE_DATA_COMPACTION ]
  [ ICEBERG_MERGE_ON_READ_BEHAVIOR ]
  [ ENABLE_ICEBERG_MERGE_ON_READ ]
  [ TABLE_PROPERTIES ( '<key>' [ , '<key>' , ... ] ) ]
  [ ENABLE_SCHEMA_EVOLUTION ]
  [ ALLOW_V3_EXPRESSION_DEFAULTS ]

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> UPGRADE TO ICEBERG VERSION 3

ALTER ICEBERG TABLE [ IF EXISTS ] dataGovnPolicyTagAction

ALTER ICEBERG TABLE [ IF EXISTS ] <table_name> searchOptimizationAction

Where

clusteringAction ::=
  {
     CLUSTER BY ( <expr> [ , <expr> , ... ] )
     /* { SUSPEND | RESUME } RECLUSTER is valid action */
   | { SUSPEND | RESUME } RECLUSTER
   | DROP CLUSTERING KEY
  }

Where

tableColumnAction ::=
  {
     ADD [ COLUMN ] [ IF NOT EXISTS ] <col_name> <col_type> [ DEFAULT <col_default> ]
        [ inlineConstraint ]
        [ COLLATE '<collation_specification>' ]

   | RENAME COLUMN <col_name> TO <new_col_name>

   | ALTER | MODIFY [ ( ]
                          , [ COLUMN ] <col1_name> { [ SET ] NOT NULL | DROP NOT NULL }
                          , [ COLUMN ] <col1_name> [ [ SET DATA ] TYPE ] <type>
                          , [ COLUMN ] <col1_name> COMMENT '<string>'
                          , [ COLUMN ] <col1_name> UNSET COMMENT
                          , [ COLUMN ] <col1_name> SET WRITE DEFAULT <col_write_default>
                          , [ COLUMN ] <col1_name> DROP WRITE DEFAULT
                        [ , [ COLUMN ] <col2_name> ... ]
                        [ , ... ]
                    [ ) ]

   | DROP [ COLUMN ] [ IF EXISTS ] <col1_name> [, <col2_name> ... ]
  }

  inlineConstraint ::=
    [ NOT NULL ]
    [ CONSTRAINT <constraint_name> ]
    {
        UNIQUE
      | PRIMARY KEY
      | [ FOREIGN KEY ] REFERENCES <ref_table_name> [ ( <ref_col_name> ) ]
      | CHECK ( <expr> )
    }
    [ <constraint_properties> ]

Where

dataGovnPolicyTagAction ::=
  {
      SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
    | UNSET TAG <tag_name> [ , <tag_name> ... ]
  }
  |
  {
      ADD ROW ACCESS POLICY <policy_name> ON ( <col_name> [ , ... ] )
    | DROP ROW ACCESS POLICY <policy_name>
    | DROP ROW ACCESS POLICY <policy_name> ,
        ADD ROW ACCESS POLICY <policy_name> ON ( <col_name> [ , ... ] )
    | DROP ALL ROW ACCESS POLICIES
  }
  |
  {
      SET AGGREGATION POLICY <policy_name>
        [ ENTITY KEY ( <col_name> [, ... ] ) ]
        [ FORCE ]
    | UNSET AGGREGATION POLICY
  }
  |
  {
      SET JOIN POLICY <policy_name>
        [ FORCE ]
    | UNSET JOIN POLICY
  }
  |
  ADD [ COLUMN ] [ IF NOT EXISTS ] <col_name> <col_type>
    [ [ WITH ] MASKING POLICY <policy_name>
          [ USING ( <col1_name> , <cond_col_1> , ... ) ] ]
    [ [ WITH ] PROJECTION POLICY <policy_name> ]
    [ [ WITH ] TAG ( <tag_name> = '<tag_value>'
          [ , <tag_name> = '<tag_value>' , ... ] ) ]
  |
  {
    { ALTER | MODIFY } [ COLUMN ] <col1_name>
        SET MASKING POLICY <policy_name>
          [ USING ( <col1_name> , <cond_col_1> , ... ) ] [ FORCE ]
      | UNSET MASKING POLICY
  }
  |
  {
    { ALTER | MODIFY } [ COLUMN ] <col1_name>
        SET PROJECTION POLICY <policy_name>
          [ FORCE ]
      | UNSET PROJECTION POLICY
  }
  |
  { ALTER | MODIFY } [ COLUMN ] <col1_name> SET TAG
      <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
      , [ COLUMN ] <col2_name> SET TAG
          <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
  |
  { ALTER | MODIFY } [ COLUMN ] <col1_name> UNSET TAG <tag_name> [ , <tag_name> ... ]
                   , [ COLUMN ] <col2_name> UNSET TAG <tag_name> [ , <tag_name> ... ]

Where

searchOptimizationAction ::=
  {
     ADD SEARCH OPTIMIZATION [
       ON <search_method_with_target> [ , <search_method_with_target> ... ]
     ]

   | DROP SEARCH OPTIMIZATION [
       ON { <search_method_with_target> | <column_name> | <expression_id> }
          [ , ... ]
     ]
  }

Parameters

NameRequiredDescription
table_nameIdentifier for the table to modify. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
RENAME TO new_table_nameRenames the specified table with a new identifier that is not currently used by any other tables in the schema. For more information about table identifiers, see Identifier requirements. When an object (table, column, etc.) is renamed, other objects that reference it must be updated with the new name.
SET ...Specifies one or more properties/parameters to set for the external table (separated by blank spaces, commas, or new lines):
REPLACE_INVALID_CHARACTERS = { TRUE | FALSE }Specifies whether to replace invalid UTF-8 characters with the Unicode replacement character (�) in query results. You can only set this parameter for tables that use an external Iceberg catalog. TRUE replaces invalid UTF-8 characters with the Unicode replacement character. FALSE leaves invalid UTF-8 characters unchanged. Snowflake returns a user error message when it encounters invalid UTF-8 characters in a Parquet data file. If not specified, the Iceberg table defaults to the parameter value for the schema, database, or account. The schema takes precedence over the database, and the database takes precedence over the account. Default: FALSE
CATALOG_SYNC = 'snowflake_open_catalog_integration_name'Specifies the name of a catalog integration configured for Snowflake Open Catalog. Snowflake syncs the table with an external catalog in your Snowflake Open Catalog account. For more information about syncing Snowflake-managed Iceberg tables with Open Catalog, see Sync a Snowflake-managed table with Snowflake Open Catalog. For more information about this parameter, see CATALOG_SYNC.
DATA_RETENTION_TIME_IN_DAYS = integerSpecifies the retention period for a Snowflake-managed table or an externally managed table so that Time Travel actions (SELECT, CLONE, UNDROP) can be performed on historical data in the table. For more information, see Understanding & using Time Travel. If you set this parameter at the table level for Apache Iceberg tables, Snowflake writes the value to the history.expire.max-snapshot-age-ms table property in the Iceberg metadata. For a detailed description of this object-level parameter, as well as more information about object parameters, see Parameters. Values: Standard Edition: 0 or 1 Enterprise Edition: 0 to 90 for permanent tables Default: Standard Edition: 1 Enterprise Edition (or higher): 1 (unless a different default value was specified at the schema, database, or account level) Note A value of 0 effectively disables Time Travel for the table.
AUTO_REFRESH = { TRUE | FALSE }Specifies whether Snowflake should automatically poll the external Iceberg catalog that is associated with the table for metadata updates. If no value is specified for the REFRESH_INTERVAL_SECONDS parameter on the catalog integration, Snowflake uses a default refresh interval of 30 seconds. For more information, see automated refresh. Default: FALSE Note Using AUTO_REFRESH with INFER_SCHEMA isn’t supported.
TARGET_FILE_SIZE = '{ AUTO | 16MB | 32MB | 64MB | 128MB }'Specifies a target Parquet file size for the table. '{ 16MB | 32MB | 64MB | 128MB }' specifies a fixed target file size for the table. 'AUTO' works differently, depending on the table type: Snowflake-managed tables: AUTO specifies that Snowflake should choose the file size for the table based on table characteristics such as size, DML patterns, ingestion workload, and clustering configuration. Snowflake automatically adjusts the file size, starting at 16 MB, for better read and write performance in Snowflake. Use this option to optimize table performance in Snowflake. Externally managed tables: AUTO specifies that Snowflake should aggressively scale to the largest file size (128 MB). For more information, see Set a target file size. This value corresponds to the Iceberg property write.target-file-size-bytes. For how Snowflake converts between the two, see Iceberg table properties. Default: AUTO
PATH_LAYOUT = { FLAT | HIERARCHICAL }Specifies the path layout that Snowflake uses when writing Parquet data files to the table. You can set this parameter for an existing table. To reset the parameter to the default (FLAT), use UNSET PATH_LAYOUT. For more information about this parameter, see PATH_LAYOUT.
STORAGE_SERIALIZATION_POLICY = { COMPATIBLE | OPTIMIZED }Specifies the storage serialization policy that Snowflake uses to encode and compress the data files it writes to the table. You can set this parameter only for externally managed Iceberg tables, including tables in a catalog-linked database. For Snowflake-managed tables, you can’t change the storage serialization policy after you create the table. COMPATIBLE: Snowflake performs encoding and compression of data files that ensures interoperability with third-party compute engines. OPTIMIZED: Snowflake performs encoding and compression of data files that ensures the best table performance within Snowflake.
CONTACT purpose = contact [ , purpose = contact ... ]Associate the existing object with one or more contacts. For a list of valid purposes, see Associate a contact with an object. You cannot set the CONTACT property with other properties in the same statement.
LOG_EVENT_LEVEL = { ERROR | WARN | INFO | DEBUG }Specifies the severity level of automated refresh log events that should be ingested and made available in the active event table. The LOG_EVENT_LEVEL parameter determines which events to capture based on the following values: ERROR: Events that signal a change requiring human intervention to resolve. WARN: Events that signal an issue that can be resolved without human intervention. INFO: Informational events, such as successfully processed refresh batches. DEBUG: High-volume events. Note There is no default severity level. To capture events, you must set the severity level at either the Iceberg table level or account level. For more information, see Monitor automated refresh events.
ERROR_LOGGING = { TRUE | FALSE }Specifies whether to turn on error logging for the table. When error logging is turned on, DML statements and supported data loading methods record errors in the table’s error table. TRUE turns on error logging for the table. An INSERT, UPDATE, or MERGE statement on the table that encounters a supported error no longer fails. Instead, it writes the other rows and records the error. For COPY INTO and Snowpipe, the ON_ERROR copy option still determines how a load handles errors and which errors are recorded. To set this property for an existing table, use a role that owns the table. FALSE turns off error logging for the table. If the table has an error table, turning off error logging drops the error table and the errors in it. The error table stores the source data of each error. Before you turn on error logging for a table that stores sensitive data, review which roles can query the error table, as described in Access control requirements for error tables. For more information, see Introduction to error logging. For DML statements, see Error logging for DML statements. For the errors that error logging records when you load files with COPY INTO or Snowpipe, see Error logging for COPY INTO and Snowpipe. Note If the OPT_OUT_ERROR_LOGGING parameter is set to TRUE for a session, DML statements, CREATE TABLE ... AS SELECT statements, and COPY INTO statements in the session don’t record errors, regardless of whether error logging is turned on for specific tables. For Snowpipe, only the value that’s set for the account applies. For more information, see Prevent or limit error logging.
ENABLE_DATA_COMPACTION = { TRUE | FALSE }Specifies whether Snowflake should enable data compaction on the table. You can only set this parameter for Snowflake-managed tables. TRUE: Snowflake performs data compaction on the table. FALSE: Snowflake doesn’t perform data compaction on the table. Default: TRUE For more information, see ENABLE_DATA_COMPACTION and Set data compaction.
ICEBERG_MERGE_ON_READ_BEHAVIOR = { 'AUTO' | 'ENABLED' | 'DISABLED' }Specifies how Snowflake performs row-level updates (UPDATE, DELETE, MERGE) on this Apache Iceberg™ table. Selects between merge-on-read (which writes Iceberg delete files alongside the data) and copy-on-write (which rewrites entire data files). If you don’t set this parameter, the Iceberg table inherits the setting from the schema, database, or account. The schema takes precedence over the database, and the database takes precedence over the account. A value set on the table can be published as write.delete.mode, write.update.mode, and write.merge.mode. On a Snowflake-managed table, writes from an external engine through Snowflake Horizon Catalog can update this parameter by setting those properties. On an externally managed table, a refresh can adopt those properties into this parameter. For details, see Write-mode property synchronization. The parameter values are case-insensitive. Values: 'AUTO': Snowflake selects merge-on-read or copy-on-write based on the table’s Iceberg format version and management mode. For details, see ICEBERG_MERGE_ON_READ_BEHAVIOR parameter. 'ENABLED': The table uses merge-on-read. For tables that conform to v2 of the Apache Iceberg™ table specification, Snowflake writes positional delete files for row-level deletes. For tables that conform to v3, Snowflake writes deletion vectors when conditions are met. 'DISABLED': The table uses copy-on-write for all DML operations. Default: 'AUTO' For a detailed description of this parameter, see ICEBERG_MERGE_ON_READ_BEHAVIOR parameter.
ENABLE_ICEBERG_MERGE_ON_READ = { TRUE | FALSE }Warning This parameter is deprecated. Use ICEBERG_MERGE_ON_READ_BEHAVIOR instead. The legacy parameter is still honored when ICEBERG_MERGE_ON_READ_BEHAVIOR is at its default ('AUTO'), but it will return an error in a future release. Specifies whether the table uses merge-on-read behavior. If you don’t set this parameter, the Iceberg table defaults to the merge-on-read behavior that is specified for the schema, database, or account. The schema takes precedence over the database, and the database takes precedence over the account. Values: TRUE: The table uses merge-on-read behavior. Depending on whether the table conforms to v2 or v3 of the Apache Iceberg™ table specification, the behavior is as described in the following list: If the table conforms with v2, Snowflake uses positional delete files for row-level deletes. If the table conforms with v3, Snowflake uses deletion vectors for row-level deletes when conditions are met. Note: Setting this parameter to TRUE does not enable merge-on-read for Snowflake-managed v2 Iceberg tables. When ICEBERG_MERGE_ON_READ_BEHAVIOR is at its default ('AUTO'), this setting routes through the auto matrix, which keeps Snowflake-managed v2 tables on copy-on-write. To enable merge-on-read for a Snowflake-managed v2 table, set ICEBERG_MERGE_ON_READ_BEHAVIOR = 'ENABLED' on the table, schema, database, or account. FALSE: The table uses copy-on-write behavior. Default: TRUE For a detailed description of this parameter, see Deprecated: ENABLE_ICEBERG_MERGE_ON_READ.
TABLE_PROPERTIES = ( 'key' = 'value' [ , 'key' = 'value' , ... ] )Sets Iceberg table properties. Some keys map to Snowflake parameters. Snowflake stores other keys as Iceberg properties. Property names are case-sensitive. You can’t set or unset format-version with this clause. To change the format version of an existing table, use UPGRADE TO ICEBERG VERSION. For the mapping, rejected keys, and examples, see Iceberg table properties.
TIME_TRAVEL_TIMESTAMP_SOURCE = { 'SNOWFLAKE_METADATA' | 'ICEBERG_METADATA' }Preview Feature — Open Available to all accounts. Specifies which timeline Snowflake uses to resolve a timestamp in an AT | BEFORE clause for the table. SNOWFLAKE_METADATA (the default) uses the Snowflake transaction timeline. ICEBERG_METADATA uses the snapshot commit times recorded in the Iceberg table metadata. ICEBERG_METADATA is supported for externally managed tables and isn’t supported for Snowflake-managed tables. You can set this parameter at the account, database, schema, or table level. For more information, see Query a table at a timestamp.
ENABLE_SCHEMA_EVOLUTION = { TRUE | FALSE }Enables or disables automatic changes to the table schema from data loaded into the table from source files, including: Added columns. By default, schema evolution is limited to a maximum of 100 added columns per load operation. To request more than 100 added columns per load operation, contact Snowflake Support. The NOT NULL constraint can be dropped from any number of columns missing in new data files. Setting it to TRUE enables automatic table schema evolution. The default FALSE disables automatic table schema evolution. Note Loading data from files evolves the table columns when all of the following are true: The COPY INTO <table> statement includes the MATCH_BY_COLUMN_NAME option. The role used to load the data has the EVOLVE SCHEMA or OWNERSHIP privilege on the table. For Snowpipe, the role that owns the pipe loads the data. Additionally, for schema evolution with CSV, when used with MATCH_BY_COLUMN_NAME and PARSE_HEADER, ERROR_ON_COLUMN_COUNT_MISMATCH must be set to false. If the files contain nested data, also set the INFER_NESTED_TYPES copy option to TRUE. Otherwise, loads that add nested columns might fail. For more information, see Create and evolve Snowflake-managed Iceberg tables.
MATCH_BY_COLUMN_NAME = { CASE_INSENSITIVE | CASE_SENSITIVE }For Parquet Direct tables (preview), controls how column names in Parquet files are matched against the table schema during refresh. If you switch from CASE_INSENSITIVE to CASE_SENSITIVE, Snowflake keeps honoring the column name casings that it already recorded for the table. For more information, see CREATE ICEBERG TABLE (Parquet files in object storage).
ALLOW_V3_EXPRESSION_DEFAULTS = { TRUE | FALSE }For Snowflake-managed Iceberg v3 tables only, specifies whether the table allows column defaults that Snowflake can’t evaluate to a constant, such as CURRENT_DATE(), sequences, and identity columns. These defaults aren’t written to Iceberg metadata, so only Snowflake writes use them. You can’t set this parameter to FALSE or unset it while the table has an expression, sequence, or identity default. For more information, see ALLOW_V3_EXPRESSION_DEFAULTS and Use expression defaults with Snowflake-managed tables.
UNSETCurrently, you can only unset the following parameters with this command: REPLACE_INVALID_CHARACTERS CATALOG_SYNC LOG_EVENT_LEVEL ENABLE_DATA_COMPACTION ICEBERG_MERGE_ON_READ_BEHAVIOR ENABLE_ICEBERG_MERGE_ON_READ ENABLE_SCHEMA_EVOLUTION ALLOW_V3_EXPRESSION_DEFAULTS TABLE_PROPERTIES UNSET TABLE_PROPERTIES takes a list of property names and must name at least one. Unsetting a property that maps to a Snowflake setting also unsets that setting. For the mapping and the keys you can’t unset, see Iceberg table properties.
UPGRADE TO ICEBERG VERSION 3Upgrades the table in place from Iceberg version 2 (v2) to version 3 (v3). The table keeps its name, privileges, and downstream references. The upgrade is permanent; you can’t downgrade a v3 table to v2. For a Snowflake-managed table, you can restore the pre-upgrade v2 table by using a Time Travel clone. For more information, see Restore the pre-upgrade v2 table. Supported for Snowflake-managed tables and for externally managed tables with CATALOG_SOURCE = ICEBERG_REST. For more information, see Upgrade an Apache Iceberg™ table from version 2 to version 3.
CLUSTER BY ( expr [ , expr , ... ] )Specifies (or modifies) one or more table columns or column expressions as the clustering key for the table. These are the columns/expressions for which clustering is maintained by Automatic Clustering. To learn more about clustering, see Clustering Keys & Clustered Tables.
SUSPEND | RESUME RECLUSTEREnables or disables Automatic Clustering for the table.
DROP CLUSTERING KEYDrops the clustering key for the table.
ADD [ COLUMN ] [ IF NOT EXISTS ] col_name col_data_type [ DEFAULT col_default ] [ inlineConstraint ] [ COLLATE 'collation_specification' ] [ , ... ]Adds a new column. You can specify a default value, an inline constraint, and a collation specification. For additional details about table column actions, see: CREATE | ALTER TABLE … CONSTRAINT CREATE MASKING POLICY CREATE TAG You can perform ADD COLUMN operations on multiple columns in the same command. If you aren’t sure whether the column already exists, you can specify IF NOT EXISTS when adding the column. If the column already exists, ADD COLUMN has no effect on the existing column and doesn’t result in an error. Note You can’t specify IF NOT EXISTS if you are also specifying any of the following for the new column: AUTOINCREMENT, or IDENTITY UNIQUE, PRIMARY KEY, or FOREIGN KEY
  • DEFAULT col_default — For Iceberg version 3 (v3) tables only, specifies the default value for the column. If the data type for the column is string, you must surround the default value with single quotes. The value you specify is used as both the initial default and write default for the column. To change the write default for the column, use ALTER ICEBERG TABLE … ALTER COLUMN … SET WRITE DEFAULT. Important For externally managed Iceberg tables, the default value must be a static value; you can’t specify an expression or function for the value. This requirement is in accordance with the Iceberg v3 specification and applies to both the initial default and write default. For Snowflake-managed v3 Iceberg tables, you can also specify SQL expressions, sequences, and identity columns as defaults. Defaults that Snowflake can’t evaluate to a constant require the ALLOW_V3_EXPRESSION_DEFAULTS parameter. For more information, see Use expression defaults with Snowflake-managed tables. For more information about using default values with Iceberg tables, see Use default values with Apache Iceberg™ tables.
RENAME COLUMN col_name to new_col_nameRenames the specified column to a new name that’s not currently used for any other columns in the table. You can’t rename a column that’s part of a clustering key. When you rename an object, such as a table or column, you must update other objects that reference it with the new name.
{ ALTER | MODIFY } COLUMN col_name ...Modifies the properties for a column.
SET WRITE DEFAULT col_defaultFor Iceberg version 3 (v3) tables only, specifies the write default value for the column. If the data type for the column is string, you must surround the default value with single quotes. If the column already has a write default, you can use this setting to change the write default. Important For externally managed Iceberg tables, the default value must be a static value; you can’t specify an expression or function for the value. This requirement is in accordance with the Iceberg v3 specification and applies to both the initial default and write default. For Snowflake-managed v3 Iceberg tables, you can also specify SQL expressions, sequences, and identity columns as defaults. Defaults that Snowflake can’t evaluate to a constant require the ALLOW_V3_EXPRESSION_DEFAULTS parameter. For more information, see Use expression defaults with Snowflake-managed tables. You can’t change the write default on a table that has ALLOW_V3_EXPRESSION_DEFAULTS = TRUE. For more information about using default values with Iceberg tables, see Use default values with Apache Iceberg™ tables.
DROP WRITE DEFAULTFor Iceberg version 3 (v3) tables only, drops the write default value for the column. For more information about using default values with Iceberg tables, see Use default values with Apache Iceberg™ tables.
DROP COLUMN [ IF EXISTS ] col_name [ CASCADE | RESTRICT ]Removes the specified column from the table. If you aren’t sure whether the column already exists, you can specify IF EXISTS when dropping the column. If the column doesn’t exist, DROP COLUMN has no effect and doesn’t result in an error. Dropping a column is a metadata-only operation. It doesn’t immediately re-write the micro-partitions and therefore doesn’t immediately free up the space used by the column. Typically, the space within an individual micro-partition is freed the next time that the micro-partition is re-written, which is typically when a write is done either due to DML (INSERT, UPDATE, DELETE) or re-clustering.
TAG tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ]Specifies the tag name and the tag string value. The tag value is always a string, and the maximum number of characters for the tag value is 256. For information about specifying tags in a statement, see Tag quotas.
policy_nameIdentifier for the policy; must be unique for your schema.
ADD ROW ACCESS POLICY policy_name ON (col_name [ , ... ])Adds a row access policy to the table. At least one column name must be specified. Additional columns can be specified with a comma separating each column name. Use this expression to add a row access policy to both an event table and an external table.
DROP ROW ACCESS POLICY policy_nameDrops a row access policy from the table. Use this clause to drop the policy from the table.
DROP ROW ACCESS POLICY policy_name, ADD ROW ACCESS POLICY policy_name ON ( col_name [ , ... ] )Drops the row access policy that is set on the table and adds a row access policy to the same table in a single SQL statement.
DROP ALL ROW ACCESS POLICIESDrops all row access policy associations from the table. This expression is helpful when a row access policy is dropped from a schema before dropping the policy from an event table. Use this expression to drop row access policy associations from the table. Suppose that a row access policy applied to the table when the backup was created, and the policy was later dropped. After you restore the table from a backup, you can’t query it until you run an ALTER TABLE command with the DROP ALL ROW ACCESS POLICIES clause.
SET AGGREGATION POLICY policy_name
[ ENTITY KEY (col_name [ , ... ]) ] [ FORCE ]Assigns an aggregation policy to the table. Use the optional ENTITY KEY parameter to define which columns uniquely identity an entity within the table. For more information, see Implementing entity-level privacy with aggregation policies. Use the optional FORCE parameter to atomically replace an existing aggregation policy with the new aggregation policy.
UNSET AGGREGATION POLICYDetaches an aggregation policy from the table.
SET JOIN POLICY policy_name
[ FORCE ]Assigns a join policy to the table. Use the optional FORCE parameter to atomically replace an existing join policy with the new join policy.
UNSET JOIN POLICYDetaches a join policy from the table.
{ ALTER | MODIFY } [ COLUMN ] ...
  • FORCE — Replaces a masking or projection policy that is currently set on a column with a different policy in a single statement. Note that using the FORCE keyword with a masking policy requires the data type of the policy in the ALTER TABLE statement (i.e. STRING) to match the data type of the masking policy currently set on the column (i.e. STRING). If a masking policy is not currently set on the column, specifying this keyword has no effect. For details, see: Replace a masking policy on a column or Replace a projection policy.
USING ( col_name , cond_col_1 ... )Specifies the arguments to pass into the conditional masking policy SQL expression. The first column in the list specifies the column for the policy conditions to mask or tokenize the data and must match the column to which the masking policy is set. The additional columns specify the columns to evaluate to determine whether to mask or tokenize the data in each row of the query result when a query is made on the first column. If the USING clause is omitted, Snowflake treats the conditional masking policy as a normal masking policy.
ADD SEARCH OPTIMIZATIONAdds search optimization for the entire table or, if you specify the optional ON clause, for specific columns. Note Search optimization can be expensive to maintain, especially if the data in the table changes frequently. For more information, see Search optimization cost estimation and management.
ON search_method_with_target [, search_method_with_target ... ]Specifies that you want to configure search optimization for specific columns (instead of the entire table). For search_method_with_target, use an expression with the following syntax:Copy code <search_method>( <target> [ , <target> , ... ] [ , ANALYZER => '<analyzer_name>' ] ) Where: search_method specifies one of the following methods that optimizes queries for a particular type of predicate: Search method Description FULL_TEXT Predicates that use VARCHAR (text) types. EQUALITY Equality and IN predicates. SUBSTRING Predicates that match substrings and regular expressions (for example, [ NOT ] LIKE, [ NOT ] ILIKE, [ NOT ] RLIKE, and REGEXP_LIKE).ExpandShow lessSee more target specifies the column or an asterisk (*). Depending on the value of search_method, you can specify a column of one of the following types: Search method Supported targets FULL_TEXT Columns of VARCHAR (text) data types. EQUALITY Columns of numerical, string, and binary data types. SUBSTRING Columns of VARCHAR (text) data types.ExpandShow lessSee more To specify all applicable columns in the table as targets, use an asterisk (*). Note that you can’t specify both an asterisk and specific column names for a given search method. However, you can specify an asterisk in different search methods. For example, you can specify the following expressions: Copy code -- Allowed ON SUBSTRING(*) ON EQUALITY(*), SUBSTRING(*) You can’t specify the following expressions: Copy code -- Not allowed ON EQUALITY(*, c1) ON EQUALITY(c1, *) ON EQUALITY(v1:path, *) ON EQUALITY(c1), EQUALITY(*) ANALYZER => 'analyzer_name' specifies the name of the text analyzer, if search_method is FULL_TEXT. For more information about search optimization analyzers, see ALTER TABLE. To specify more than one search method on a target, use a comma to separate each subsequent method and target:Copy code ALTER ICEBERG TABLE t1 ADD SEARCH OPTIMIZATION ON EQUALITY(c1), EQUALITY(c2, c3); If you run the ALTER ICEBERG TABLE … ADD SEARCH OPTIMIZATION ON … command multiple times on the same table, each subsequent command adds to the existing configuration for the table. For example, suppose that you run the following commands:Copy code ALTER ICEBERG TABLE t1 ADD SEARCH OPTIMIZATION ON EQUALITY(c1, c2); ALTER ICEBERG TABLE t1 ADD SEARCH OPTIMIZATION ON EQUALITY(c3, c4); This adds equality predicates for the columns c1, c2, c3, and c4 to the configuration for the table. This is equivalent to running the command:Copy code ALTER ICEBERG TABLE t1 ADD SEARCH OPTIMIZATION ON EQUALITY(c1, c2, c3, c4); For examples, see Enabling search optimization for specific columns.
DROP SEARCH OPTIMIZATIONRemoves search optimization for the entire table or, if you specify the optional ON clause, from specific columns. Note If a table has the search optimization property, then dropping the table and undropping it preserves the search optimization property. Removing the search optimization property from a table and then adding it back incurs the same cost as adding it the first time.
ON search_method_with_target | column_name | expression_id [ , ... ]Specifies that you want to drop the search optimization configuration for specific columns (instead of dropping search optimization for the entire table). To identify the column configuration to drop, specify one of the following: For search_method_with_target, specify a method for optimizing queries for one or more specific columns. Use the syntax described earlier. For column_name, specify the name of the column configured for search optimization. Specifying the column name drops all expressions for that column. For expression_id, specify the ID for an expression listed in the output of the DESCRIBE SEARCH OPTIMIZATION command. To specify more than one of these, use a comma between items. You can specify any combination of search methods with targets, column names, and expression IDs. For examples, see Dropping search optimization for specific columns.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | Iceberg table | OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). USAGE | External volume | USAGE | Catalog integration | Required if the table uses a catalog integration. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by