Back to Articles

Snowflake - How to recover a dropped table

Snowflake - How to recover a dropped table


In Snowflake , Find the table ID of the dropped table in the Account Usage TABLES view:

Login as ACCOUNT ADMIN or SYSADMIN,

Note: By default, time travel is enabled for 24hrs. Use below query to recover the table back.

SELECT table_id,
  table_name,
  table_schema,
  table_catalog,
  created,
  deleted,
  comment
FROM SNOWFLAKE.ACCOUNT_USAGE.TABLES
WHERE table_catalog = 'NEOVIDYA_DATABASE'
AND table_schema = 'NEOVIDYA_SCHEMA'
AND table_name = 'NEOVIDYA_TABLENAME'
AND deleted IS NOT NULL
ORDER BY deleted;

-> Output of above query will show table_id, use it to restore the table.

Undrop my_table by table ID.

UNDROP TABLE IDENTIFIER(408578);

Now you must see your table and it is recovered successfully.

Reference : https://docs.snowflake.com/en/sql-reference/sql/undrop-table