A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/developer-guide/python-connector/../../sql-reference/sql/undrop-table below:

Website Navigation


UNDROP TABLE | Snowflake Documentation

UNDROP TABLE

Restores the most recent version of a dropped table.

See also:

CREATE TABLE , ALTER TABLE , DROP TABLE , SHOW TABLES , DESCRIBE TABLE

Syntax Parameters
name

Specifies the identifier for the table to restore. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

Usage notes Examples Basic example

Restore the most recent version of a dropped table (this example builds on the examples provided for DROP TABLE):

+---------------------------------+
| status                          |
|---------------------------------|
| Table T2 successfully restored. |
+---------------------------------+
UNDROP table using the table ID

Restore a dropped table by ID using IDENTIFIER(). You can find the table ID of the specific table to undrop using the table_id column in the TABLES view. For example, if you have multiple dropped tables named my_table, and you want to restore the second-to-last dropped table my_table, follow these steps:

  1. Find the table ID of the dropped table in the Account Usage TABLES view:

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

    Copy

    +----------+------------+--------------+---------------+-------------------------------+-------------------------------+---------+
    | TABLE_ID | TABLE_NAME | TABLE_SCHEMA | TABLE_CATALOG | CREATED                       | DELETED                       | COMMENT |
    |----------+------------+--------------+---------------+-------------------------------+-------------------------------+---------|
    |   408578 | MY_TABLE   | S1           | DB1           | 2024-07-01 15:39:07.565 -0700 | 2024-07-01 15:40:28.161 -0700 | NULL    |
    +----------+------------+--------------+---------------+-------------------------------+-------------------------------+---------+
    |   408607 | MY_TABLE   | S1           | DB1           | 2024-07-01 17:43:07.565 -0700 | 2024-07-01 17:44:28.161 -0700 | NULL    |
    +----------+------------+--------------+---------------+-------------------------------+-------------------------------+---------+
    
  2. Undrop my_table by table ID. To restore the second-to-last deleted table, use table ID 408578 from the output of the previous statement. After you execute the following statement, the table is restored with its original name, my_table:

    UNDROP TABLE IDENTIFIER(408578);
    

    Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4