:doc:`Redshift <../../redshift>` / Client / restore_table_from_cluster_snapshot

***********************************
restore_table_from_cluster_snapshot
***********************************



.. py:method:: Redshift.Client.restore_table_from_cluster_snapshot(**kwargs)

  

  Creates a new table from a table in an Amazon Redshift cluster snapshot. You must create the new table within the Amazon Redshift cluster that the snapshot was taken from.

   

  You cannot use ``RestoreTableFromClusterSnapshot`` to restore a table with the same name as an existing table in an Amazon Redshift cluster. That is, you cannot overwrite an existing table in a cluster with a restored table. If you want to replace your original table with a new, restored table, then rename or drop your original table before you call ``RestoreTableFromClusterSnapshot``. When you have renamed your original table, then you can pass the original name of the table as the ``NewTableName`` parameter value in the call to ``RestoreTableFromClusterSnapshot``. This way, you can replace the original table with the table created from the snapshot.

   

  You can't use this operation to restore tables with `interleaved sort keys <https://docs.aws.amazon.com/redshift/latest/dg/t_Sorting_data.html#t_Sorting_data-interleaved>`__.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/redshift-2012-12-01/RestoreTableFromClusterSnapshot>`_  


  **Request Syntax**
  ::

    response = client.restore_table_from_cluster_snapshot(
        ClusterIdentifier='string',
        SnapshotIdentifier='string',
        SourceDatabaseName='string',
        SourceSchemaName='string',
        SourceTableName='string',
        TargetDatabaseName='string',
        TargetSchemaName='string',
        NewTableName='string',
        EnableCaseSensitiveIdentifier=True|False
    )
    
  :type ClusterIdentifier: string
  :param ClusterIdentifier: **[REQUIRED]** 

    The identifier of the Amazon Redshift cluster to restore the table to.

    

  
  :type SnapshotIdentifier: string
  :param SnapshotIdentifier: **[REQUIRED]** 

    The identifier of the snapshot to restore the table from. This snapshot must have been created from the Amazon Redshift cluster specified by the ``ClusterIdentifier`` parameter.

    

  
  :type SourceDatabaseName: string
  :param SourceDatabaseName: **[REQUIRED]** 

    The name of the source database that contains the table to restore from.

    

  
  :type SourceSchemaName: string
  :param SourceSchemaName: 

    The name of the source schema that contains the table to restore from. If you do not specify a ``SourceSchemaName`` value, the default is ``public``.

    

  
  :type SourceTableName: string
  :param SourceTableName: **[REQUIRED]** 

    The name of the source table to restore from.

    

  
  :type TargetDatabaseName: string
  :param TargetDatabaseName: 

    The name of the database to restore the table to.

    

  
  :type TargetSchemaName: string
  :param TargetSchemaName: 

    The name of the schema to restore the table to.

    

  
  :type NewTableName: string
  :param NewTableName: **[REQUIRED]** 

    The name of the table to create as a result of the current request.

    

  
  :type EnableCaseSensitiveIdentifier: boolean
  :param EnableCaseSensitiveIdentifier: 

    Indicates whether name identifiers for database, schema, and table are case sensitive. If ``true``, the names are case sensitive. If ``false`` (default), the names are not case sensitive.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'TableRestoreStatus': {
              'TableRestoreRequestId': 'string',
              'Status': 'PENDING'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED'|'CANCELED',
              'Message': 'string',
              'RequestTime': datetime(2015, 1, 1),
              'ProgressInMegaBytes': 123,
              'TotalDataInMegaBytes': 123,
              'ClusterIdentifier': 'string',
              'SnapshotIdentifier': 'string',
              'SourceDatabaseName': 'string',
              'SourceSchemaName': 'string',
              'SourceTableName': 'string',
              'TargetDatabaseName': 'string',
              'TargetSchemaName': 'string',
              'NewTableName': 'string'
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **TableRestoreStatus** *(dict) --* 

        Describes the status of a  RestoreTableFromClusterSnapshot operation.

        
        

        - **TableRestoreRequestId** *(string) --* 

          The unique identifier for the table restore request.

          
        

        - **Status** *(string) --* 

          A value that describes the current state of the table restore request.

           

          Valid Values: ``SUCCEEDED``, ``FAILED``, ``CANCELED``, ``PENDING``, ``IN_PROGRESS``

          
        

        - **Message** *(string) --* 

          A description of the status of the table restore request. Status values include ``SUCCEEDED``, ``FAILED``, ``CANCELED``, ``PENDING``, ``IN_PROGRESS``.

          
        

        - **RequestTime** *(datetime) --* 

          The time that the table restore request was made, in Universal Coordinated Time (UTC).

          
        

        - **ProgressInMegaBytes** *(integer) --* 

          The amount of data restored to the new table so far, in megabytes (MB).

          
        

        - **TotalDataInMegaBytes** *(integer) --* 

          The total amount of data to restore to the new table, in megabytes (MB).

          
        

        - **ClusterIdentifier** *(string) --* 

          The identifier of the Amazon Redshift cluster that the table is being restored to.

          
        

        - **SnapshotIdentifier** *(string) --* 

          The identifier of the snapshot that the table is being restored from.

          
        

        - **SourceDatabaseName** *(string) --* 

          The name of the source database that contains the table being restored.

          
        

        - **SourceSchemaName** *(string) --* 

          The name of the source schema that contains the table being restored.

          
        

        - **SourceTableName** *(string) --* 

          The name of the source table being restored.

          
        

        - **TargetDatabaseName** *(string) --* 

          The name of the database to restore the table to.

          
        

        - **TargetSchemaName** *(string) --* 

          The name of the schema to restore the table to.

          
        

        - **NewTableName** *(string) --* 

          The name of the table to create as a result of the table restore request.

          
    
  
  **Exceptions**
  
  *   :py:class:`Redshift.Client.exceptions.ClusterSnapshotNotFoundFault`

  
  *   :py:class:`Redshift.Client.exceptions.InProgressTableRestoreQuotaExceededFault`

  
  *   :py:class:`Redshift.Client.exceptions.InvalidClusterSnapshotStateFault`

  
  *   :py:class:`Redshift.Client.exceptions.InvalidTableRestoreArgumentFault`

  
  *   :py:class:`Redshift.Client.exceptions.ClusterNotFoundFault`

  
  *   :py:class:`Redshift.Client.exceptions.InvalidClusterStateFault`

  
  *   :py:class:`Redshift.Client.exceptions.UnsupportedOperationFault`

  