snowflake.core.table.TableResourceΒΆ
- class snowflake.core.table.TableResource(name: str, collection: TableCollection)ΒΆ
- Bases: - SchemaObjectReferenceMixin[- TableCollection]- Represents a reference to a Snowflake table. - With this table reference, you can create, update, delete and fetch information about tables, as well as perform certain actions on them. - Attributes - databaseΒΆ
- The DatabaseResource this reference belongs to. 
 - fully_qualified_nameΒΆ
- Return the fully qualified name of the object this reference points to. 
 - rootΒΆ
- The Root object this reference belongs to. 
 - Methods - create_or_alter(table: Table) NoneΒΆ
- Create or alter a table. - Parameters:
- table (Table) β The - Tableobject, including the- Tableβs properties: name; kind, cluster_by, enable_schema_evolution, change_tracking, data_retention_time_in_days, max_data_extension_time_in_days, default_ddl_collation, columns, constraints, comment are optional.
 - Examples - Creating a new table: - >>> my_schema.table["my_table"].create_or_alter(my_table_def) - See - TableCollection.createfor more examples.- Notes - Not currently implemented:
- Row access policy 
- Column masking policy 
- Search optimization 
- Tags 
- Stage file format and copy options 
- Foreign keys. 
- Rename the table. 
- If the name and tableβs name donβt match, an error will be thrown. 
- Rename or drop a column. 
 
 
- New columns can only be added to the back of the column list. 
 
 - create_or_alter_async(table: Table) PollingOperation[None]ΒΆ
- An asynchronous version of - create_or_alter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - create_or_update(table: Table) NoneΒΆ
- The - create_or_update()method is deprecated; use- create_or_alter()instead.- Create or update a table. - table: Table
- The - Tableobject, including the- Tableβs properties: name; kind, cluster_by, enable_schema_evolution, change_tracking, data_retention_time_in_days, max_data_extension_time_in_days, default_ddl_collation, columns, constraints, comment are optional.
 - Creating a new table: - >>> my_schema.table["my_table"].create_or_update(my_table_def) - See - TableCollection.createfor more examples.- Not currently implemented:
- Row access policy 
- Column masking policy 
- Search optimization 
- Tags 
- Stage file format and copy options 
- Foreign keys. 
- Rename the table. 
- If the name and tableβs name donβt match, an error will be thrown. 
- Rename or drop a column. 
 
 
- New columns can only be added to the back of the column list. 
 
 - delete() NoneΒΆ
- The - delete()method is deprecated; use- drop()instead.- Delete the table. - Deleting a table using its reference: - >>> table_ref.delete() 
 - drop(if_exists: bool | None = None) NoneΒΆ
- Drop the table. - Parameters:
- if_exists (bool, optional) β Check the existence of this table before suspending it. Default is - None, which is equivalent to- False.
 - Examples - Dropping a table using its reference: - >>> table_ref.drop() 
 - drop_async(if_exists: bool | None = None) PollingOperation[None]ΒΆ
- An asynchronous version of - drop().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - fetch() TableΒΆ
- Fetch the details of a table. - Examples - Fetching a reference to a table to print its comment: - >>> table_ref = my_schema.tables["my_table"].fetch() >>> print(table_ref.comment) - Notes - Inline constraints will become Outofline constraints because Snowflake database doesnβt tell whether a constraint is inline or out of line from Snowflake database. 
 - fetch_async() PollingOperation[Table]ΒΆ
- An asynchronous version of - fetch().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - resume_recluster(if_exists: bool | None = None) NoneΒΆ
- Resume reclustering for this table. - Parameters:
- if_exists (bool, optional) β Check the existence of this table before resuming its recluster. Default is - None, which is equivalent to- False.
 - Examples - Resume reclustering for a table using its reference`: - >>> my_schema.tables["my_table"].resume_recluster() 
 - resume_recluster_async(if_exists: bool | None = None) PollingOperation[None]ΒΆ
- An asynchronous version of - resume_recluster().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - suspend_recluster(if_exists: bool | None = None) NoneΒΆ
- Suspend reclustering for this table. - Parameters:
- if_exists (bool, optional) β Check the existence of this table before suspending its recluster. Default is - None, which is equivalent to- False.
 - Examples - Suspending reclustering for a table using its reference: - >>> my_schema.tables["my_table"].suspend_recluster() 
 - suspend_recluster_async(if_exists: bool | None = None) PollingOperation[None]ΒΆ
- An asynchronous version of - suspend_recluster().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - swap_with(to_swap_table_name: str, if_exists: bool | None = None, target_database: str | None = None, target_schema: str | None = None) NoneΒΆ
- Swap the name with another table. - Parameters:
- to_swap_table_name (str) β The name of the table we should swap the current table with. 
- if_exists (bool, optional) β Check the existence of this table before swapping its name. Default is - None, which is equivalent to- False.
- target_database (str, optional) β The name of the database where the table to be swapped with exists. The default is - None, which means the current database.
- target_schema (str, optional) β The name of the schema where the table to be swapped with exists. The default is - None, which means the current schema.
 
 - Examples - Swapping - my_tablewith- other_tablein the same schema:- >>> my_table = my_schema.tables["my_table"].swap("other_table") 
 - swap_with_async(to_swap_table_name: str, if_exists: bool | None = None, target_database: str | None = None, target_schema: str | None = None) PollingOperation[None]ΒΆ
- An asynchronous version of - swap_with().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - undelete() NoneΒΆ
- The - undelete()method is deprecated; use- undrop()instead.- Undelete the previously deleted table. - Undeleting a table using its reference: - >>> table_ref.delete() >>> table_ref.undelete() 
 - undrop() NoneΒΆ
- Undrop the previously dropped table. - Examples - Undropping a table using its reference: - >>> table_ref.drop() >>> table_ref.undrop() 
 - undrop_async() PollingOperation[None]ΒΆ
- An asynchronous version of - undrop().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.