alterStandardTableColumn

Modifies column properties on an existing Snowflake standard table.

Available attributes

Attribute

Type

Description

Required

catalogName

String

Name of the catalog (database) containing the table

No

schemaName

String

Name of the schema containing the table

No

tableName

String

Name of the table containing the column

Yes

columnName

String

Name of the column to alter

Yes

ifExists

Boolean

Only execute if the table exists

No

Nullable

Controls the NOT NULL constraint on the column.

alterNullable nested attributes

Attribute

Type

Description

Required

setNotNull

Boolean

If true, adds NOT NULL constraint

No*

dropNotNull

Boolean

If true, removes NOT NULL constraint

No*

*Exactly one of setNotNull or dropNotNull must be true.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Add NOT NULL constraint -->
  <changeSet id="add-not-null" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="MY_COLUMN">
      <pro-snowflake:alterNullable setNotNull="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Remove NOT NULL constraint -->
  <changeSet id="drop-not-null" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="MY_COLUMN">
      <pro-snowflake:alterNullable dropNotNull="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Data type

Changes the column data type. Snowflake supports increasing precision or length for compatible types.

alterDataType nested attributes

Attribute

Type

Description

Required

newDataType

String

The new data type

Yes

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Increase VARCHAR length -->
  <changeSet id="increase-varchar-length" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="MY_COLUMN">
      <pro-snowflake:alterDataType newDataType="VARCHAR(500)"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Default value

Sets or drops the default value for a column. Note: Snowflake only supports SET DEFAULT for sequence-based defaults.

alterDefault nested attributes

Attribute

Type

Description

Required

newSequenceDefault

String

Sequence expression (e.g., SEQ.NEXTVAL)

No*

dropDefault

Boolean

If true, drops the default value

No*

*Exactly one of newSequenceDefault or dropDefault must be specified.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set sequence default -->
  <changeSet id="set-sequence-default" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="ID">
      <pro-snowflake:alterDefault newSequenceDefault="MY_SCHEMA.MY_SEQ.NEXTVAL"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Drop default -->
  <changeSet id="drop-default" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="ID">
      <pro-snowflake:alterDefault dropDefault="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Masking policy

Sets or unsets a masking policy on the column.

alterMaskingPolicy nested attributes

Attribute

Type

Description

Required

policyName

String

Name of the masking policy to apply

No*

using

String

Additional columns for conditional masking

No

force

Boolean

If true, forces policy replacement

No

unsetPolicy

Boolean

If true, removes the masking policy

No*

*Specify either policyName to set or unsetPolicy to remove.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set masking policy -->
  <changeSet id="set-masking-policy" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="CUSTOMERS" columnName="EMAIL">
      <pro-snowflake:alterMaskingPolicy policyName="EMAIL_MASK" force="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Set masking policy with conditional columns -->
  <changeSet id="set-masking-policy-conditional" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="CUSTOMERS" columnName="SSN">
      <pro-snowflake:alterMaskingPolicy
                policyName="SSN_MASK"
                using="ROLE_COLUMN"
                force="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Unset masking policy -->
  <changeSet id="unset-masking-policy" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="CUSTOMERS" columnName="EMAIL">
      <pro-snowflake:alterMaskingPolicy unsetPolicy="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Projection policy

Sets or unsets a projection policy on the column.

alterProjectionPolicy nested attributes

Attribute

Type

Description

Required

policyName

String

Name of the projection policy

No*

force

Boolean

If true, forces policy replacement

No

unsetPolicy

Boolean

If true, removes the projection policy

No*

*Specify either policyName to set or unsetPolicy to remove.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set projection policy -->
  <changeSet id="set-projection-policy" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="SENSITIVE_DATA" columnName="SECRET_COLUMN">
      <pro-snowflake:alterProjectionPolicy policyName="NO_PROJECTION" force="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Unset projection policy -->
  <changeSet id="unset-projection-policy" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="SENSITIVE_DATA" columnName="SECRET_COLUMN">
      <pro-snowflake:alterProjectionPolicy unsetPolicy="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Comment

Sets or unsets the column comment.

alterColumnComment nested attributes

Attribute

Type

Description

Required

newComment

String

New comment text

No*

unsetComment

Boolean

If true, removes the comment

No*

*Exactly one of newComment or unsetComment must be specified.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set column comment -->
  <changeSet id="set-column-comment" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="MY_COLUMN">
      <pro-snowflake:alterColumnComment newComment="Customer email address"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Remove column comment -->
  <changeSet id="unset-column-comment" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="MY_TABLE" columnName="MY_COLUMN">
      <pro-snowflake:alterColumnComment unsetComment="true"/>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>

Tags

Sets or unsets tags on the column.

alterColumnTags nested attributes

Attribute

Type

Description

Required

setTags

Object

Map of tag names to values to set

No*

unsetTags

Object

List of tag names to unset

No*

*Exactly one of setTags or unsetTags must be specified.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Set column tags -->
  <changeSet id="set-column-tags" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="CUSTOMERS" columnName="EMAIL">
      <pro-snowflake:alterColumnTags>
        <pro-snowflake:setTags>
          <pro-snowflake:entry key="PII" value="true"/>
          <pro-snowflake:entry key="SENSITIVITY" value="HIGH"/>
        </pro-snowflake:setTags>
      </pro-snowflake:alterColumnTags>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
  <!-- Unset column tags -->
  <changeSet id="unset-column-tags" author="examples">
    <pro-snowflake:alterStandardTableColumn tableName="CUSTOMERS" columnName="EMAIL">
      <pro-snowflake:alterColumnTags>
        <pro-snowflake:unsetTags>
          <pro-snowflake:unsetTag tagName="PII"/>
          <pro-snowflake:unsetTag tagName="SENSITIVITY"/>
        </pro-snowflake:unsetTags>
      </pro-snowflake:alterColumnTags>
    </pro-snowflake:alterStandardTableColumn>
  </changeSet>
</databaseChangeLog>