TRUNCATE
Description
Deletes all of the rows from a table without doing a table scan (Redshift SQL Language Reference TRUNCATE)
Grammar Syntax
TRUNCATE [TABLE] table_nameSample Source Patterns
Setup data
Redshift
CREATE TABLE transaction_values_test
(
col1 INTEGER
);Snowflake
TRUNCATE in a default transaction behavior procedure (without NONATOMIC clause)
Since the TRUNCATE statement automatically commits the transaction it is executed in, any of its usages will generate a COMMIT statement in Snowflake to emulate this behavior.
Since a COMMIT statement is generated the same BEGIN TRANSACTION statement generation will be applied to TRUNCATE. For more information check the COMMIT translation specification.
Redshift
Snowflake
TRUNCATE in a procedure with NONATOMIC behavior
The NONATOMIC behavior from Redshift is emulated in Snowflake by using the session parameter AUTOCOMMIT set to true.
Since the AUTOCOMMIT session parameter is assumed to be true by SnowConvert, the TRUNCATE statement inside NONATOMIC procedures is left as is, there is no need to generate a COMMIT statement because every statement is automatically commited when executed.
Redshift
Snowflake
Known Issues
1. TRUNCATE inside a nested procedure call
In Redshift, when a COMMIT statement is specified in a nested procedure call, the command will commit all pending work from previous statements in the current and parent scopes. Committing the parent scope actions is not supported in Snowflake, when this case is detected an FDM will be generated.
Redshift
Snowflake
Known Issues
There are no known issues.
Related EWIs
SSC-FDM-RS0006: Called procedure contains usages of COMMIT/ROLLBACK, modifying the current transaction in child scopes is not supported in Snowflake.
Last updated
