SnowConvert AI - SQL Server-Azure Synapse - ALTER¶
Translation reference for all the DDL statements that are preceded by the ALTER keyword.
TABLE¶
Description¶
Modifies a table definition by altering, adding, or dropping columns and constraints. ALTER TABLE also reassigns and rebuilds partitions, or disables and enables constraints and triggers. (https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql)
CHECK CONSTRAINT¶
Applies to
SQL Server
Azure Synapse Analytics
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
SnowConvert AI comments out ALTER TABLE ... CHECK CONSTRAINT ... and ALTER TABLE ... NOCHECK CONSTRAINT ... statements because enabling or disabling constraints is not applicable in Snowflake.
This behavior applies to the CHECK CONSTRAINT action. It does not apply to unsupported ADD CHECK (...) constraint definitions, which continue to be flagged separately.
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Known Limitations¶
Snowflake constraints are informational only, so SQL Server workflows that depend on enabling or disabling constraints must be redesigned manually.
This section only covers the
CHECK CONSTRAINTaction. UnsupportedCHECKconstraint definitions may still emit SSC-EWI-0035.
ADD¶
Description¶
Note
In SQL Server, the ADD clause permits multiple actions per ADD, whereas Snowflake only allows a sequence of ADD column actions. Consequently, SnowConvert AI divides the ALTER TABLE ADD clause into individual ALTER TABLE statements.
There is a subset of functionalities provided by the ADD keyword, allowing the addition of different elements to the target table. These include:
Column definition
Computed column definition
Table constraint
Column set definition
TABLE CONSTRAINT¶
Applies to
SQL Server
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
Specifies the properties of a PRIMARY KEY, FOREIGN KEY, UNIQUE, or CHECK constraint that is part of a new column definition added to a table by using ALTER TABLE. (https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-column-constraint-transact-sql)
Translation for column constraints is relatively straightforward. There are several parts of the syntax that are not required or not supported in Snowflake.
These parts include:
CLUSTERED | NONCLUSTEREDWITH FILLFACTOR = fillfactorWITH ( index_option [, ...n ] )ON { partition_scheme_name ( partition\_column\_name ) | filegroup | "default" }NOT FOR REPLICATIONCHECK [ NOT FOR REPLICATION ]
Syntax in SQL Server¶
Syntax in Snowflake¶
Sample Source Patterns¶
Multiple ALTER TABLE instances¶
SQL Server¶
Snowflake¶
DEFAULT within constraints¶
SQL Server¶
Snowflake¶
Known Issues¶
1. DEFAULT is only supported within CREATE TABLE and ALTER TABLE ... ADD COLUMN
SQL Server supports defining a DEFAULT property within a constraint, while Snowflake only allows that when adding the column through CREATE TABLE or ALTER TABLE ... ADD COLUMN. DEFAULT properties within the ADD CONSTRAINT syntax are not supported and will be translated to ALTER TABLE ALTER COLUMN.
CHECK¶
Applies to
SQL Server
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
When CHECK clause is in the ALTER statement, SnowConvert AI will comment out the entire statement, since it is not supported.
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Known Issues¶
1. ALTER TABLE CHECK clause is not supported in Snowflake.
The entire ALTER TABLE CHECK clause is commented out, since it is not supported in Snowflake.
Related EWIs¶
SSC-EWI-0035: Check statement not supported.
CONNECTION¶
Applies to
SQL Server
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
When CONNECTION clause is in the ALTER statement, SnowConvert AI will comment out the entire statement, since it is not supported.
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Known Issues¶
1. ALTER TABLE CONNECTION clause is not supported in Snowflake.
The entire ALTER TABLE CONNECTION clause is commented out, since it is not supported in Snowflake.
Related EWIs¶
SSC-EWI-0109: Alter Table syntax is not applicable in Snowflake.
DEFAULT¶
Applies to
SQL Server
Description¶
When DEFAULT clause is in the ALTER statement, SnowConvert AI will comment out the entire statement, since it is not supported.
The only functional scenario happens when the table definition is on the same file, in this way the default is added in the column definition.
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Known Issues¶
1. ALTER TABLE DEFAULT clause is not supported in Snowflake.
The entire ALTER TABLE DEFAULT clause is commented out, since it is not supported in Snowflake.
Related EWIs¶
SSC-FDM-TS0020: Default constraint was commented out and may have been added to a table definition.
FOREIGN KEY¶
Applies to
SQL Server
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
Snowflake supports the grammar for Referential Integrity Constraints, and their properties to facilitate the migration from other databases.
SQL Server¶
Snowflake¶
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Note
Constraints are not enforced in Snowflake, excepting NOT NULL.
Primary and Foreign Key are only used for documentation purposes more than design constraints.
ON PARTITION¶
Applies to
SQL Server
Note
Non-relevant statement.
Warning
Notice that this statement is removed from the migration because it is a non-relevant syntax. It means that it is not required in Snowflake.
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
In Transact SQL Server, the on partition statement is used inside alter statements and is used to divide the data across the database. For more information, see the SQL Server partitioned tables and indexes documentation.
Sample Source Patterns¶
On Partition¶
Notice that in this example the ON PARTITION has been removed. This is because Snowflake provides an integrated partitioning methodology. Thus, the syntax is not relevant.
SQL SERVER¶
Snowflake¶
PRIMARY KEY¶
Applies to
SQL Server
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
SQL Server primary key has many clauses that are not applicable for Snowflake. So, most of the statement will be commented out.
Syntax in SQL Server¶
Syntax in Snowflake¶
Sample Source Patterns¶
Warning
Notice that WITH FILLFACTOR statement has been removed from the translation because it is not relevant in Snowflake syntax.
SQL Server¶
Snowflake¶
COLUMN DEFINITION¶
ALTER TABLE ADD column_name
Applies to
SQL Server
Azure Synapse Analytics
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
Specifies the properties of a column that are added to a table by using ALTER TABLE.
Adding a column definition in Snowflake does have some differences compared to SQL Server.
For instance, several parts of the SQL Server grammar are not required or entirely not supported by Snowflake. These include:
Additionally, a couple other parts are partially supported, and require additional work to be implemented to properly emulate the original functionality. Specifically, we’re talking about the MASKED WITH property, which will be covered in the patterns section of this page.
SQL Server¶
Snowflake¶
Sample Source Patterns¶
Basic pattern¶
This pattern showcases the removal of elements from the original ALTER TABLE.
SQL Server¶
Snowflake¶
COLLATE¶
Collation allows you to specify broader rules when talking about string comparison.
SQL Server¶
Since the collation rule nomenclature varies from SQL Server to Snowflake, it is necessary to make adjustments.
Snowflake¶
MASKED WITH¶
This pattern showcases the translation for MASKED WITH property. CREATE OR REPLACE MASKING POLICY is inserted somewhere before the first usage, and then referenced by a SET MASKING POLICY clause.
The name of the new MASKING POLICY will be the concatenation of the name and arguments of the original MASKED WITH FUNCTION, as seen below:
SQL Server¶
Snowflake¶
DEFAULT¶
This pattern showcases some of the basic translation scenarios for DEFAULT property.
SQL Server¶
Snowflake¶
ENCRYPTED WITH¶
This pattern showcases the translation for ENCRYPTED WITH property, which is commented out in the output code.
SQL Server¶
Snowflake¶
NOT NULL¶
The SQL Server NOT NULL clause has the same pattern and functionality as the Snowflake NOT NULL clause
SQL Server¶
Snowflake¶
IDENTITY¶
This pattern showcases the translation for IDENTITY. The NOT FOR REPLICATION portion is removed in Snowflake.
SQL Server¶
Snowflake¶
Unsupported clauses¶
FILESTREAM¶
The original behavior of FILESTREAM is not replicable in Snowflake, and merits commenting out the entire ALTER TABLE statement.
SQL Server¶
Snowflake¶
SPARSE¶
In SQL Server, SPARSE is used to define columns that are optimized for NULL storage. However, when we’re using Snowflake, we are not required to use this clause.
Snowflake performs optimizations over tables automatically, which mitigates the need for manual user-made optimizations.
SQL Server¶
Snowflake¶
ROWGUIDCOL¶
SQL Server¶
Snowflake¶
Known Issues¶
1. Roles and users have to be previously set up for masking policies
Snowflake’s Masking Policies can be applied to columns only after the policies were created. This requires the user to create the policies and assign them to roles, and these roles to users, to work properly. Masking Policies can behave differently depending on which user is querying.
Warning
SnowConvert AI does not perform this setup automatically.
2. Masking policies require a Snowflake Enterprise account or higher.
The Snowflake documentation states that masking policies are available on Enterprise or higher rank accounts.
Note
For further details visit CREATE MASKING POLICY — Snowflake Documentation.
3. DEFAULT only supports constant values
SQL Server’s DEFAULT property is partially supported by Snowflake, as long as its associated value is a constant.
4. FILESTREAM clause is not supported in Snowflake.
The entire FILESTSTREAM clause is commented out, since it is not supported in Snowflake.
5. SPARSE clause is not supported in Snowflake.
The entire SPARSE clause is commented out, since it is not supported in Snowflake. When it is added within an ALTER COLUMN statement, and it’s the only modification being made to the column, the entire statement is removed since it’s no longer adding anything.
Related EWIs¶
SSC-EWI-0040: Statement Not Supported.
SSC-EWI-TS0061: ALTER COLUMN not supported.
SSC-EWI-TS0078: Default value not allowed in Snowflake.
SSC-FDM-TS0009: Encrypted with not supported in Snowflake.
SSC-FDM-TS0021: A MASKING POLICY was created as a substitute for MASKED WITH.
SSC-FDM-TS0022: The user must previously define the masking role.
SSC-PRF-0002: Case-insensitive columns can decrease the performance of queries.
COLUMN CONSTRAINT¶
ALTER TABLE ADD COLUMN … COLUMN CONSTRAINT
Applies to
SQL Server
Azure Synapse Analytics
Description¶
Specifies the properties of a PRIMARY KEY, FOREIGN KEY or CHECK that is part of a new column constraint added to a table by using Alter Table.
SQL Server¶
Snowflake¶
Where:
CHECK¶
Applies to
SQL Server
Description¶
Note
Some parts in the output code are omitted for clarity reasons.
When CHECK clause is in the ALTER statement, SnowConvert AI will comment out the entire statement, since it is not supported.
Sample Source Patterns¶
SQL Server¶
Snowflake¶
Known Issues¶
1. ALTER TABLE CHECK clause is not supported in Snowflake.
The entire ALTER TABLE CHECK clause is commented out, since it is not supported in Snowflake.
Related EWIs¶
SSC-EWI-0035: Check statement not supported.
FOREIGN KEY¶
Applies to
SQL Server
Azure Synapse Analytics
Description¶
The syntax for the Foreign Key is fully supported by Snowflake, except for the [ NOT FOR REPLICATION ] and the WITH CHECK clauses.
SQL Server¶
Review the following SQL Server documentation for more information.
Snowflake¶
Sample Source Patterns¶
General case¶
SQL Server¶
Snowflake¶
WITH CHECK / NO CHECK case¶
Notice that Snowflake logic does not support the CHECK clause in the creation of foreign keys. The WITH CHECK statement is marked as not supported. Besides, the WITH NO CHECK clause is removed because it is the default behavior in Snowflake and the equivalence is the same.
Please, review the following examples to have a better understanding of the translation.
SQL Server¶
Snowflake¶
Known Issues¶
1. NOT FOR REPLICATION clause.
Snowflake has a different approach to the replication cases. Please, review the following documentation.
2. WITH CHECK clause.
Snowflake does not support the WITH CHECK statement. Review the following documentation for more information.
PRIMARY KEY / UNIQUE¶
Applies to
SQL Server
Azure Synapse Analytics
Description¶
All of the optional clauses of the PRIMARY KEY / UNIQUE constraint are removed in Snowflake.
Syntax in SQL Server