Undrop a table in Snowflake / How to use time-travel on a dropped table in Snowflake

Dropping a Snowflake table does not permanently remove it from the system. A version of the dropped table is retained in Time Travel for the number of days specified by the DATA_RETENTION_TIME_IN_DAYS parameter for the table:

  • Within the Time Travel retention period, a dropped table can be restored using the UNDROP TABLE command

After dropping a table, creating a table with the same name creates a new version of the table. The dropped version of the previous table can still be restored using the following method:

  • Rename the current version of the table to a different name.
  • Use the UNDROP TABLE command to restore the previous version.

For Example, consider you dropped table t1, and you created the table t1 again. To recover the data:

ALTER TABLE t1 RENAME TO t1_Backup;
undrop table t1;

nVector

posted on 29 Oct 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds