Views the information about MaxCompute internal tables, views, materialized views, external tables, clustered tables, or transactional tables.

Syntax

-- View the information about an internal table or a view. 
desc <table_name|view_name> [partition (<pt_spec>)]; 
-- View the information about a materialized view, an external table, a clustered table, or a transactional table. You can also execute this statement to view extended information about an internal table. 
desc extended <table_name|mv_name>; 

Parameters

  • table_name: required. The name of the table whose information you want to view.
  • view_name: required. The name of the view whose information you want to view.
  • mv_name: the name of the materialized view whose information you want to view.
  • pt_spec: optional. The table partition whose information you want to view. The value of this parameter is in the (partition_col1 = partition_col_value1, partition_col2 = partition_col_value2, ...) format.
  • extended: This parameter is required if you want to view the information about a materialized view, an external table, a clustered table, or a transactional table. This parameter is used to display extended information about a table. You can also use this parameter to view extended information about an internal table, such as whether a column of the internal table can contain null values.

Return values

  • Owner: the owner of the table or view.
  • Project: the project to which the table or view belongs.
  • TableComment: the comment on the table or view.
  • CreateTime: the time when the table or view was created.
  • LastDDLTime: the time when the data definition language (DDL) statement of the table or view was last modified.
  • LastModifiedTime: the time when data of the table or view was last modified.
  • Lifecycle: the lifecycle in the unit of days.
  • InternalTable: indicates whether the object is an internal table. This parameter is returned only for tables.
  • VirtualView: indicates whether the object is a view. This parameter is returned only for views.
  • Size: the size of the table. Unit: bytes.
  • Native Columns: the column information of the table or view.
  • Partition Columns: the information about partition key columns. This parameter is returned only for partitioned tables.

Examples

  • Example 1: View the information about the test1 table. Sample statement:
    desc test1;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$maoXXX@alibaba-inc.com | Project: $project_name                      |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2020-11-16 17:47:48                                      |
    | LastDDLTime:              2020-11-16 17:47:48                                      |
    | LastModifiedTime:         2020-11-16 17:47:48                                      |
    +------------------------------------------------------------------------------------+
    | InternalTable: YES      | Size: 0                                                  |
    +------------------------------------------------------------------------------------+
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field           | Type       | Label | Comment                                     |
    +------------------------------------------------------------------------------------+
    | key             | string     |       |                                             |
    +------------------------------------------------------------------------------------+
  • Example 2: View the information about the sale_detail table. Sample statement:
    desc sale_detail;
    The following result is returned:
    +--------------------------------------------------------------------+
    | Owner: ALIYUN$maoXXX@alibaba-inc.com | Project: $project_name      |
    | TableComment:                                                      |
    +--------------------------------------------------------------------+
    | CreateTime:               2017-06-28 15:05:17                      |
    | LastDDLTime:              2017-06-28 15:05:17                      |
    | LastModifiedTime:         2017-06-28 15:05:17                      |
    +--------------------------------------------------------------------+
    | 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 the detailed information about the sale_detail_ctas1 table. Sample statement:
    desc extended sale_detail_ctas1;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$maoXXX@alibaba-inc.com | Project: $project_name                      |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2021-07-07 15:29:53                                      |
    | LastDDLTime:              2021-07-07 15:29:53                                      |
    | LastModifiedTime:         2021-07-07 15:29:53                                      |
    | 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:                  98cb8a38733c49eabed4735173818147                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    | StoredAs:                 AliOrc                                                   |
    | CompressionStrategy:      normal                                                   |
    +------------------------------------------------------------------------------------+
    The sale_date and region columns are considered as common columns. They are not partition key columns.
  • Example 4: View the information about the sale_detail_ctas2 table. Sample statement:
    desc sale_detail_ctas2;
    The following result is returned:
    +--------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name       |
    | TableComment:                                                      |
    +--------------------------------------------------------------------+
    | CreateTime:               2017-06-28 15:42:17                      |
    | LastDDLTime:              2017-06-28 15:42:17                      |
    | LastModifiedTime:         2017-06-28 15:42:17                      |
    +--------------------------------------------------------------------+
    | InternalTable: YES      | Size: 0                                  |
    +--------------------------------------------------------------------+
    | Native Columns:                                                    |
    +--------------------------------------------------------------------+
    | Field           | Type       | Label | Comment                     |
    +--------------------------------------------------------------------+
    | shop_name       | string     |       |                             |
    | customer_id     | string     |       |                             |
    | total_price     | double     |       |                             |
    | sale_date       | string     |       |                             |
    | region          | string     |       |                             |
    +--------------------------------------------------------------------+
  • Example 5: View the details about the sale_detail_like table. Sample statement:
    desc extended sale_detail_like;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name                       |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2021-07-07 15:40:38                                      |
    | LastDDLTime:              2021-07-07 15:40:38                                      |
    | LastModifiedTime:         2021-07-07 15:40:38                                      |
    | 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         |              |
    +------------------------------------------------------------------------------------+
    | Partition Columns:                                                                 |
    +------------------------------------------------------------------------------------+
    | sale_date       | string     |                                                     |
    | region          | string     |                                                     |
    +------------------------------------------------------------------------------------+
    | Extended Info:                                                                     |
    +------------------------------------------------------------------------------------+
    | TableID:                  61782ff7713f426e9d6f91d5deeac99a                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    | StoredAs:                 AliOrc                                                   |
    | CompressionStrategy:      normal                                                   |
    +------------------------------------------------------------------------------------+
    Except for the lifecycle configuration, all properties, such as field types and partition types, of the sale_detail_like table are the same as those of the sale_detail table.
    Note The size of data in the output of the DESC table_name statement includes the data size of the recycle bin. If you want to clear the recycle bin, execute the PURGE TABLE table_name statement. Then, execute the DESC table_name statement to view the size of data that excludes the size of data in the recycle bin. You can also execute the SHOW RECYCLEBIN statement to view the details about data in the recycle bin for your project.
  • Example 6: View the information about the test_newtype table. Sample statement:
    desc test_newtype;
    The following result is returned:
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field           | Type       | Label | Comment                                     |
    +------------------------------------------------------------------------------------+
    | 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) |       |                                            |
    +------------------------------------------------------------------------------------+
    
    OK
  • Example 7: View the information about the hash-clustered table t1. This table is a non-partitioned table. The clustering attribute is displayed in Extended Info. Sample statement:
    desc extended t1;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name                       |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2020-11-16 18:00:56                                      |
    | LastDDLTime:              2020-11-16 18:00:56                                      |
    | LastModifiedTime:         2020-11-16 18:00:56                                      |
    +------------------------------------------------------------------------------------+
    | 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:                  e6b06f705dc34a36a5b72e5af486cab7                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    | StoredAs:                 AliOrc                                                   |
    | CompressionStrategy:      normal                                                   |
    | ClusterType:              hash                                                     |
    | BucketNum:                1024                                                     |
    | ClusterColumns:           [c]                                                      |
    | SortColumns:              [c ASC]                                                  |
    +------------------------------------------------------------------------------------+
    
    OK
  • Example 8: View the information about the hash-clustered table t2. This table is a partitioned table. The clustering attribute is displayed in Extended Info. Sample statement:
    desc extended t2;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name                       |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime: 2017-12-25 11:18:26                                                    |
    | LastDDLTime: 2017-12-25 11:18:26                                                   |
    | LastModifiedTime: 2017-12-25 11:18:26                                              |
    | Lifecycle: 2                                                                       |
    +------------------------------------------------------------------------------------+
    | InternalTable: YES | Size: 0                                                       |
    +------------------------------------------------------------------------------------+
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field | Type   | Label | Comment                                                   |
    +------------------------------------------------------------------------------------+
    | a     | string |       |                                                           |
    | b     | string |       |                                                           |
    | c     | bigint |       |                                                           |
    +------------------------------------------------------------------------------------+
    | Partition Columns:                                                                 |
    +------------------------------------------------------------------------------------+
    | dt    | string |                                                                   |
    +------------------------------------------------------------------------------------+
    | Extended Info:                                                                     |
    +------------------------------------------------------------------------------------+
    | TableID: 91a3395d3ef64b4d9ee1d2852755                                              |
    | IsArchived: false                                                                  |
    | PhysicalSize: 0                                                                    |
    | FileNum: 0                                                                         |
    | ClusterType: hash                                                                  |
    | BucketNum: 1024                                                                    |
    | ClusterColumns: [c]                                                                |
    | SortColumns: [c ASC]                                                               |
    +------------------------------------------------------------------------------------+
    
    OK
  • Example 9: View the information about the range-clustered table t3. This table is a non-partitioned table. The clustering attribute is displayed in Extended Info. Sample statement:
    desc extended t3;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name                       |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2020-11-16 18:01:05                                      |
    | LastDDLTime:              2020-11-16 18:01:05                                      |
    | LastModifiedTime:         2020-11-16 18:01:05                                      |
    +------------------------------------------------------------------------------------+
    | 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:                  38d170aca2684f4baadbbe1931a6ae1f                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    | StoredAs:                 AliOrc                                                   |
    | CompressionStrategy:      normal                                                   |
    | ClusterType:              range                                                    |
    | BucketNum:                1024                                                     |
    | ClusterColumns:           [c]                                                      |
    | SortColumns:              [c ASC]                                                  |
    +------------------------------------------------------------------------------------+
    
    OK
  • Example 10: View the information about the range-clustered table t4. This table is a partitioned table. The clustering attribute is displayed in Extended Info. Sample statement:
    desc extended t4;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@alibaba-inc.com | Project: $project_name                       |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2020-11-16 19:17:48                                      |
    | LastDDLTime:              2020-11-16 19:17:48                                      |
    | LastModifiedTime:         2020-11-16 19:17:48                                      |
    +------------------------------------------------------------------------------------+
    | 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:                  6ebc3432e283449188c861427bcd6ee4                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    | StoredAs:                 AliOrc                                                   |
    | CompressionStrategy:      normal                                                   |
    | ClusterType:              range                                                    |
    | BucketNum:                0                                                        |
    | ClusterColumns:           [c]                                                      |
    | SortColumns:              [c ASC]                                                  |
    +------------------------------------------------------------------------------------+
    
    OK
  • Example 11: Check whether the non-partitioned table t5 is a transactional table. Sample statement:
    Note We recommend that you use the MaxCompute client to check whether a table is a transactional table. The version of the MaxCompute client must be V0.35.4. For more information about how to download and use the MaxCompute client, see MaxCompute client. Other tools may not be updated to display transactional information.
    desc extended t5;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@aliyun.com | Project: $project_name                            |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2021-02-18 10:56:27                                      |
    | LastDDLTime:              2021-02-18 10:56:27                                      |
    | LastModifiedTime:         2021-02-18 10:56:27                                      |
    +------------------------------------------------------------------------------------+
    | InternalTable: YES      | Size: 0                                                  |
    +------------------------------------------------------------------------------------+
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field    | Type   | Label | ExtendedLabel | Nullable | DefaultValue | Comment      |
    +------------------------------------------------------------------------------------+
    | id       | bigint |       |               | true     | NULL         |              |
    +------------------------------------------------------------------------------------+
    | Extended Info:                                                                     |
    +------------------------------------------------------------------------------------+
    ...
    | Transactional:            true                                                     |
    +------------------------------------------------------------------------------------+
  • Example 12: Check whether the partitioned table t6 is a transactional table. Sample statement:
    Note We recommend that you use the MaxCompute client to check whether a table is a transactional table. The version of the MaxCompute client must be V0.35.4. For more information about how to download and use the MaxCompute client, see MaxCompute client. Other tools may not be updated to display transactional information.
    desc extended t6;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$xxxxx@test.aliyunid.com | Project: $project_name                     |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2021-02-18 15:34:54                                      |
    | LastDDLTime:              2021-02-18 15:34:54                                      |
    | LastModifiedTime:         2021-02-18 15:34:54                                      |
    +------------------------------------------------------------------------------------+
    | InternalTable: YES      | Size: 0                                                  |
    +------------------------------------------------------------------------------------+
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field           | Type       | Label | Comment                                     |
    +------------------------------------------------------------------------------------+
    | id              | bigint     |       |                                             |
    +------------------------------------------------------------------------------------+
    | Partition Columns:                                                                 |
    +------------------------------------------------------------------------------------+
    | ds              | string     |                                                     |
    +------------------------------------------------------------------------------------+
    | Extended Info:                                                                     |
    +------------------------------------------------------------------------------------+
    ...
    | Transactional:            true                                                     |
    +------------------------------------------------------------------------------------+
  • Example 13: View information about the materialized view mv.
    desc extended mv;
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | Owner: ALIYUN$****@aliyunid.com | Project: ****                                    |
    | TableComment:                                                                      |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2021-08-01 17:50:15                                      |
    | LastDDLTime:              2021-08-01 17:50:15                                      |
    | LastModifiedTime:         2021-08-01 17:50:15                                      |
    +------------------------------------------------------------------------------------+
    | InternalTable: YES      | Size: 0                                                  |
    +------------------------------------------------------------------------------------+
    | Native Columns:                                                                    |
    +------------------------------------------------------------------------------------+
    | Field    | Type   | Label | ExtendedLabel | Nullable | DefaultValue | Comment      |
    +------------------------------------------------------------------------------------+
    | page_id  | string |       |               | true     | NULL         |              |
    | _c1      | bigint |       |               | true     | NULL         |              |
    +------------------------------------------------------------------------------------+
    | Extended Info:                                                                     |
    +------------------------------------------------------------------------------------+
    | TableID:                  e4a7f1169588400ab39bc3076426****                         |
    | IsArchived:               false                                                    |
    | PhysicalSize:             0                                                        |
    | FileNum:                  0                                                        |
    +------------------------------------------------------------------------------------+
  • Example 14: View partition information about the partitioned table sale_detail.
    desc sale_detail partition (sale_date='201310',region='beijing');
    The following result is returned:
    +------------------------------------------------------------------------------------+
    | PartitionSize: 2109112                                                             |
    +------------------------------------------------------------------------------------+
    | CreateTime:               2015-10-10 08:48:48                                      |
    | LastDDLTime:              2015-10-10 08:48:48                                      |
    | LastModifiedTime:         2015-10-11 01:33:35                                      |
    +------------------------------------------------------------------------------------+
    OK

Related statements

  • CREATE TABLE: Creates a non-partitioned table, a partitioned table, an external table, or a clustered table.
  • CREATE VIEW: Creates a view or updates an existing view based on a query statement.
  • CREATE MATERIALIZED VIEW: Creates a materialized view that supports clustering and partitioning based on the data for materialized view scenarios.
  • 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 partitions of a materialized view.
  • SELECT MATERIALIZED VIEW: Queries the status of a materialized view.
  • DROP MATERIALIZED VIEW: Drops an existing materialized view.