DESC TABLE/VIEW
Displays information about MaxCompute internal tables, views, materialized views, foreign tables, clustered tables, or transactional tables.
Command format
-- View information about an internal table or a view.
DESC <table_name|view_name> [PARTITION (<pt_spec>)];
-- View information about a materialized view, foreign table, clustered table, or transactional table. You can also use this command to view extended information about an internal table.
DESC extended <table_name|mv_name>; Parameters
Parameter Name | Description |
table_name | Required. The name of the table that you want to view. |
view_name | Required. The name of the view that you want to view. |
mv_name | The name of the materialized view that you want to query. |
pt_spec | Optional. The partition that you want to view in a partitioned table. The format is |
extended | Include this parameter to display extended information for a materialized view, foreign table, clustered table, or transactional table. You can also use this parameter to view extended information for an internal table, such as the non-null property of a column. |
Return values
Parameter name | Description |
Owner | The account of the table or view owner. |
Project | The project to which the table or view belongs. |
TableComment | The comment of the table or view. |
CreateTime | The time when the table or view was created. |
LastDDLTime | The time when the Data Definition Language (DDL) of the table or view was last modified. |
LastModifiedTime | The time when the data in the table or view was last modified. |
LastAccessTime | The time when the data in the table or view was last accessed. This time is for reference only. A difference of up to 24 hours can exist between this value and the actual last access time. If data is frequently accessed, the LastAccessTime value is not updated if it has been updated in the last 24 hours. This reduces the performance overhead caused by frequent updates. |
Lifecycle | The lifecycle in days. |
InternalTable | Indicates whether the object is an internal table. This parameter is returned only for table objects. |
VirtualView | Indicates whether the object is a view. This parameter is returned only for view objects. |
Size | The table size in bytes. |
NativeColumns | The column information of the table or view. |
PartitionColumns | The partition key column information. This parameter is returned only for partitioned tables. |
Usage examples
The size returned by
DESC table_nameincludes data in the recycle bin.To exclude data in the recycle bin from the size calculation, first run
PURGE TABLE table_name. Then, runDESC table_name.Run
SHOW recyclebinto view details of data in the recycle bin for the current project.
Example 1: View information about a created non-partitioned table
Create a test table.
CREATE TABLE test_table ( key STRING );View information about the test_table table.
DESC test_table;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 15:04:49 | | LastDDLTime: 2025-12-15 15:04:50 | | LastModifiedTime: 2025-12-15 15:04:49 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | Comment | +------------------------------------------------------------------------------------+ | key | string | | | +------------------------------------------------------------------------------------+
Example 2: View information about a created partitioned table
Create a test table.
CREATE TABLE test_table_partition ( shop_name STRING, customer_id STRING, total_price DOUBLE ) PARTITIONED BY ( sale_date STRING, region STRING );View information about the created table.
DESC test_table_partition;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 15:08:27 | | LastDDLTime: 2025-12-15 15:08:27 | | LastModifiedTime: 2025-12-15 15:08:27 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | Comment | +------------------------------------------------------------------------------------+ | shop_name | string | | | | customer_id | string | | | | total_price | double | | | +------------------------------------------------------------------------------------+ | Partition Columns: | +------------------------------------------------------------------------------------+ | sale_date | string | | | region | string | | +------------------------------------------------------------------------------------+
Example 3: View detailed information about a partitioned table
Create a test table.
CREATE TABLE IF NOT EXISTS test_table_partition ( shop_name STRING, customer_id STRING, total_price DOUBLE ) PARTITIONED BY ( sale_date STRING, region STRING );View information about the created table.
DESC EXTENDED test_table_partition;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 15:08:27 | | LastDDLTime: 2025-12-15 15:08:27 | | LastModifiedTime: 2025-12-15 15:08:27 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | shop_name | string | | | true | NULL | | | customer_id | string | | | true | NULL | | | total_price | double | | | true | NULL | | +------------------------------------------------------------------------------------+ | Partition Columns: | +------------------------------------------------------------------------------------+ | sale_date | string | | | region | string | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: 8c4d6ed34c964326b45d0435a3babe45 | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | encryption_enable: false | +------------------------------------------------------------------------------------+
Example 4: View detailed information about a table with a lifecycle
Create a test table.
CREATE TABLE sale_detail_ctas( shop_name STRING, customer_id STRING, total_price DOUBLE, sale_date STRING, region STRING ) LIFECYCLE 10;View detailed information about the created table.
DESC EXTENDED sale_detail_ctas;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 15:13:22 | | LastDDLTime: 2025-12-15 15:13:22 | | LastModifiedTime: 2025-12-15 15:13:22 | | Lifecycle: 10 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | shop_name | string | | | true | NULL | | | customer_id | string | | | true | NULL | | | total_price | double | | | true | NULL | | | sale_date | string | | | true | NULL | | | region | string | | | true | NULL | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: 8271334ac9724d09a4973b5b3d536f4c | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | ColdStorageStatus: N/A | | encryption_enable: false | | StorageTier: Standard | | StorageTierLastModifiedTime: 2025-12-15 15:13:22 | +------------------------------------------------------------------------------------+
Example 5: View information about a created table that contains fields of different data types
Create a test table.
CREATE TABLE test_newtype( c1 TINYINT, c2 SMALLINT, c3 INT, c4 BIGINT, c5 FLOAT, c6 DOUBLE, c7 DECIMAL, c8 BINARY, c9 TIMESTAMP, c10 ARRAY<MAP<BIGINT, BIGINT>>, c11 MAP<STRING, ARRAY<BIGINT>>, c12 STRUCT<s1:STRING, s2:BIGINT>, c13 VARCHAR(20) );View detailed information about the created table.
DESC test_newtype;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:09:18 | | LastDDLTime: 2025-12-15 16:09:18 | | LastModifiedTime: 2025-12-15 16:09:18 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | Comment | +------------------------------------------------------------------------------------+ | c1 | tinyint | | | | c2 | smallint | | | | c3 | int | | | | c4 | bigint | | | | c5 | float | | | | c6 | double | | | | c7 | decimal(38,18) | | | | c8 | binary | | | | c9 | timestamp | | | | c10 | array<map<bigint,bigint>> | | | | c11 | map<string,array<bigint>> | | | | c12 | struct<s1:string,s2:bigint> | | | | c13 | varchar(20) | | | +------------------------------------------------------------------------------------+
Example 6: View information about a created hash-clustered non-partitioned table
Create a test table.
CREATE TABLE hash_clustered_nonpar ( a STRING, b STRING, c BIGINT ) CLUSTERED BY (c) SORTED BY (c ASC) INTO 1024 BUCKETS;View detailed information about the created table.
DESC EXTENDED hash_clustered_nonpar;Returned result.
Cluster properties appear in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:18:07 | | LastDDLTime: 2025-12-15 16:18:07 | | LastModifiedTime: 2025-12-15 16:18:07 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | a | string | | | true | NULL | | | b | string | | | true | NULL | | | c | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: 904e6a0d76624346903d59a2b536d0a3 | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | ColdStorageStatus: N/A | | encryption_enable: false | | ClusterType: hash | | BucketNum: 1024 | | ClusterColumns: [c] | | SortColumns: [c ASC] | | StorageTier: Standard | | StorageTierLastModifiedTime: 2025-12-15 16:18:07 | +------------------------------------------------------------------------------------+
Example 7: View information about a created hash-clustered partitioned table
Create a test table.
CREATE TABLE hash_clustered_par ( a STRING, b STRING, c BIGINT ) PARTITIONED BY ( dt STRING ) CLUSTERED BY (c) SORTED BY (c ASC) INTO 1024 BUCKETS LIFECYCLE 2;View detailed information about the created table.
DESC EXTENDED hash_clustered_par;Returned result.
Cluster properties appear in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:26:24 | | LastDDLTime: 2025-12-15 16:26:24 | | LastModifiedTime: 2025-12-15 16:26:24 | | Lifecycle: 2 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | a | string | | | true | NULL | | | b | string | | | true | NULL | | | c | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Partition Columns: | +------------------------------------------------------------------------------------+ | dt | string | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: 5680f0711add43928389db3655d9183e | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | encryption_enable: false | | ClusterType: hash | | BucketNum: 1024 | | ClusterColumns: [c] | | SortColumns: [c ASC] | +------------------------------------------------------------------------------------+
Example 8: View information about a range-clustered non-partitioned table
Create a test table.
CREATE TABLE range_clustered_nonpar ( a STRING, b STRING, c BIGINT ) RANGE CLUSTERED BY (c);View detailed information about the created table.
DESC EXTENDED range_clustered_nonpar;Returned result.
Cluster properties appear in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:30:45 | | LastDDLTime: 2025-12-15 16:30:45 | | LastModifiedTime: 2025-12-15 16:30:45 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | a | string | | | true | NULL | | | b | string | | | true | NULL | | | c | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: bf01d946c4b24c0e9c54ccfe8750b7c2 | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | ColdStorageStatus: N/A | | encryption_enable: false | | ClusterType: range | | BucketNum: 0 | | ClusterColumns: [c] | | StorageTier: Standard | | StorageTierLastModifiedTime: 2025-12-15 16:30:45 | +------------------------------------------------------------------------------------+
Example 9: View information about a range-clustered partitioned table
Create a test table.
CREATE TABLE range_clustered_par ( a STRING, b STRING, c BIGINT ) PARTITIONED BY ( dt STRING ) RANGE CLUSTERED BY (c);View detailed information about the created table.
DESC EXTENDED range_clustered_par;Returned result.
Cluster properties appear in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:33:09 | | LastDDLTime: 2025-12-15 16:33:09 | | LastModifiedTime: 2025-12-15 16:33:09 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | a | string | | | true | NULL | | | b | string | | | true | NULL | | | c | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Partition Columns: | +------------------------------------------------------------------------------------+ | dt | string | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: bdc4f6897691479ea9c315664f26fe39 | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | encryption_enable: false | | ClusterType: range | | BucketNum: 0 | | ClusterColumns: [c] | +------------------------------------------------------------------------------------+
Example 10: Check whether a non-partitioned table is a transactional table
Use the MaxCompute client version 0.35.4 or later to check whether a table is a transactional table.
Other tools may not support this feature if they are not upgraded to the required version, and the query result may omit transactional information.
Create a test table.
CREATE TABLE tran_nonpar ( id BIGINT ) TBLPROPERTIES ('transactional'='true');View detailed information about the created table.
DESC EXTENDED tran_nonpar;Returned result.
The Transactional property appears in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:37:27 | | LastDDLTime: 2025-12-15 16:37:27 | | LastModifiedTime: 2025-12-15 16:37:27 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | id | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: 43e9710c2b4c404780a7be9998afb23e | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | Transactional: true | | IsolationMin: NONSTRICT_SNAPSHOT_ISOLATION | | odps.timemachine.retention.days: 1 | | ColdStorageStatus: N/A | | encryption_enable: false | | StorageTier: Standard | | StorageTierLastModifiedTime: 2025-12-15 16:37:27 | +------------------------------------------------------------------------------------+
Example 11: Check whether a partitioned table is a transactional table
Use the MaxCompute client version 0.35.4 or later to check whether a table is a transactional table.
Other tools may not support this feature if they are not upgraded to the required version, and the query result may omit transactional information.
Create a test table.
CREATE TABLE tran_par ( id BIGINT ) PARTITIONED BY ( ds STRING ) TBLPROPERTIES ('transactional'='true');View detailed information about the created table.
DESC EXTENDED tran_par;Returned result.
The Transactional property appears in the Extended Info section.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:42:26 | | LastDDLTime: 2025-12-15 16:42:26 | | LastModifiedTime: 2025-12-15 16:42:26 | +------------------------------------------------------------------------------------+ | InternalTable: YES | Size: 0 | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | id | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Partition Columns: | +------------------------------------------------------------------------------------+ | ds | string | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | TableID: d4dd59b15f7940bcad4cb5efdb42f242 | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: AliOrc | | CompressionStrategy: normal | | Transactional: true | | IsolationMin: NONSTRICT_SNAPSHOT_ISOLATION | | odps.timemachine.retention.days: 1 | | encryption_enable: false | +------------------------------------------------------------------------------------+
Example 12: Query information about the materialized view mv
Create a test table.
-- Create a test base table. CREATE TABLE page_view_logs ( page_id STRING, user_id STRING, view_timestamp BIGINT ); -- Create a materialized view to calculate the page views (PV) of each page. CREATE MATERIALIZED VIEW mv AS SELECT page_id, COUNT(1) AS pv_count FROM page_view_logs GROUP BY page_id;View detailed information about the materialized view.
DESC EXTENDED mv;Returned result.
+------------------------------------------------------------------------------------+ | Owner: ALIYUN$***_com | | Project: testproject | | TableComment: | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:47:51 | | LastDDLTime: 2025-12-15 16:47:51 | | LastModifiedTime: 2025-12-15 16:47:51 | +------------------------------------------------------------------------------------+ | MaterializedView: YES | | ViewText: SELECT page_id, COUNT(1) AS pv_count FROM page_view_logs GROUP BY page_id | | Rewrite Enabled: true | | AutoRefresh Enabled: false | +------------------------------------------------------------------------------------+ | Native Columns: | +------------------------------------------------------------------------------------+ | Field | Type | Label | ExtendedLabel | Nullable | DefaultValue | Comment | +------------------------------------------------------------------------------------+ | page_id | string | | | true | NULL | | | pv_count | bigint | | | true | NULL | | +------------------------------------------------------------------------------------+ | Extended Info: | +------------------------------------------------------------------------------------+ | IsOutdated: false | | TableID: a8742f3751904ec3ade23a7ecc2a2b0b | | IsArchived: false | | PhysicalSize: 0 | | FileNum: 0 | | StoredAs: CFile | | CompressionStrategy: normal | | odps.timemachine.retention.days: 1 | | ColdStorageStatus: N/A | | encryption_enable: false | | StorageTier: Standard | | StorageTierLastModifiedTime: 2025-12-15 16:47:51 | +------------------------------------------------------------------------------------+
Example 13: Query partition information of a partitioned table
Create a test table.
-- Create a test table. CREATE TABLE IF NOT EXISTS test_table_partition ( shop_name STRING, customer_id STRING, total_price DOUBLE ) PARTITIONED BY ( sale_date STRING, region STRING ); -- Create a partition. ALTER TABLE test_table_partition ADD IF NOT EXISTS PARTITION (sale_date='201310', region='beijing'); -- Use INSERT INTO to append data to the specified partition. INSERT INTO TABLE test_table_partition PARTITION (sale_date='201310', region='beijing') VALUES ('Apple Store', 'user001', 8888.0), ('Nike Store', 'user002', 1200.5), ('Starbucks', 'user001', 45.0);Query partition information for the partitioned table.
DESC test_table_partition PARTITION (sale_date='201310', region='beijing');Returned result.
+------------------------------------------------------------------------------------+ | PartitionSize: 1163 | +------------------------------------------------------------------------------------+ | CreateTime: 2025-12-15 16:54:16 | | LastDDLTime: 2025-12-15 16:54:16 | | LastModifiedTime: 2025-12-15 16:54:23 | +------------------------------------------------------------------------------------+
Related commands
CREATE TABLE: Creates a non-partitioned table, partitioned table, foreign table, or clustered table.
CREATE VIEW: Creates a view or updates an existing view based on a query statement.
CREATE MATERIALIZED VIEW: Creates a materialized view based on data that meets the requirements of materialized view scenarios. This command supports partitioning and clustering.
ALTER MATERIALIZED VIEW: Updates a materialized view, modifies the lifecycle of a materialized view, enables or disables the lifecycle of a materialized view, and deletes materialized view partitions.
SELECT MATERIALIZED VIEW: Queries the status of a materialized view.
DROP MATERIALIZED VIEW: Deletes a created materialized view.