跳到主要内容

Table

This page provides a comprehensive overview of table operations in Databend, organized by functionality for easy reference.

Table Creation

CommandDescription
CREATE TABLECreates a new table with specified columns and options
CREATE TABLE ... LIKECreates a table with the same column definitions as an existing one
CREATE TABLE ... ASCreates a table and inserts data based on the results of a SELECT query
CREATE TRANSIENT TABLECreates a table without Time Travel support
CREATE EXTERNAL TABLECreates a table with data stored in a specified external location
ATTACH TABLECreates a table by associating it with an existing table

Table Modification

CommandDescription
ALTER TABLE COLUMNModifies the structure of a table by making changes to its columns
ALTER TABLE CONNECTIONUpdates the connection settings for an external table
ALTER TABLE OPTIONModifies the Fuse engine options of a table
ALTER TABLE COMMENTUpdates the comment for a table
RENAME TABLEChanges the name of a table

Table Information

CommandDescription
DESCRIBE TABLE / SHOW FIELDSShows information about the columns in a given table
SHOW FULL COLUMNSRetrieves comprehensive details about the columns in a given table
SHOW CREATE TABLEShows the CREATE TABLE statement that creates the named table
SHOW TABLESLists the tables in the current or a specified database
SHOW TABLE STATUSShows the status of the tables in a database
SHOW DROP TABLESLists the dropped tables in the current or a specified database

Table Deletion & Recovery

CommandDescriptionRecovery Option
TRUNCATE TABLERemoves all data from a table while preserving the table's schemaFLASHBACK TABLE
DROP TABLEDeletes a tableUNDROP TABLE
VACUUM TABLEPermanently removes historical data files of a table (Enterprise Edition)Not recoverable
VACUUM DROP TABLEPermanently removes data files of dropped tables (Enterprise Edition)Not recoverable

Table Optimization

CommandDescription
ANALYZE TABLECalculates table statistics to improve query performance
OPTIMIZE TABLECompacts or purges historical data to save storage space and enhance query performance
SET CLUSTER KEYConfigures a cluster key to enhance query performance for large tables
备注

Table optimization is an advanced operation. Please carefully read the documentation before proceeding to avoid potential data loss.

开始使用 Databend Cloud
低成本
快速分析
多种数据源
弹性扩展
注册