All Products
Search
Document Center

MaxCompute:DESC TABLE/VIEW

Last Updated:Dec 15, 2025

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

Syntax

-- View information about an internal table or a view.
DESC <table_name|view_name> [PARTITION (<pt_spec>)]; 
-- View information about a materialized view, external table, clustered table, or transactional table. You can also view extended information about an internal table.
DESC extended <table_name|mv_name>; 

Parameters

  • table_name: Required. The name of the table to view.

  • view_name: Required. The name of the view to view.

  • mv_name: The name of the materialized view to query.

  • pt_spec: Optional. A specific partition of the partitioned table to view. The format is (partition_col1 = partition_col_value1, partition_col2 = partition_col_value2, ...).

  • extended: Include this parameter to display extended information for a materialized view, external table, clustered table, or transactional table. For an internal table, you can also use this parameter to view extended information, such as the non-null property of a column.

Return values

  • Owner: The account that owns the table or view.

  • Project: The project to which the table or view belongs.

  • TableComment: The comment for the table or view.

  • CreateTime: The time when the table or view was created.

  • LastDDLTime: The time when the table or view was last modified using a DDL statement.

  • 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 a reference value and may differ from the actual last access time by up to 24 hours.

    To reduce performance overhead, LastAccessTime is not updated if it has been refreshed within the last 24 hours.
  • 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 size of the table in bytes.

  • NativeColumns: The column information of the table or view.

  • PartitionColumns: The information about partition key columns. This parameter is returned only for partitioned tables.

Examples

Note
  • The Size returned by DESC table_name includes the size of data in the recycle bin.

  • To clear the recycle bin, run PURGE TABLE table_name and then run DESC table_name. The returned size will not include data in the recycle bin.

  • Run SHOW recyclebin to view details about the data in the recycle bin for the current project.

Example 1: View information about a non-partitioned table

  • Create a test table

    CREATE TABLE test_table (
        key STRING
    );
  • View information about the test_table table

    DESC test_table;
  • 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 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 table

    DESC test_table_partition;
  • 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 table

    DESC EXTENDED test_table_partition;
  • Return values

    +------------------------------------------------------------------------------------+
    | 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 table

    DESC EXTENDED sale_detail_ctas;
  • 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 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 table

    DESC test_newtype;
  • 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 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 table

    DESC EXTENDED hash_clustered_nonpar;
  • Result

    The clustering properties are displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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 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 table

    DESC EXTENDED hash_clustered_par;
  • Result

    The clustering properties are displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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 table

    DESC EXTENDED range_clustered_nonpar;
  • Result

    The clustering properties are displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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 table

    DESC EXTENDED range_clustered_par;
  • Result

    The clustering properties are displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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

Note

Use the MaxCompute client (version 0.35.4 or later) to check whether a table is a transactional table.

Other tools may not be updated and might not display the transactional information in the query result.

  • Create a test table

    CREATE TABLE tran_nonpar (
        id              BIGINT
    )
    TBLPROPERTIES ('transactional'='true');
  • View detailed information about the table

    DESC EXTENDED tran_nonpar;
  • Result

    The Transactional property is displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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

Note

Use the MaxCompute client (version 0.35.4 or later) to check whether a table is a transactional table.

Other tools may not be updated and might not display the transactional information in the query result.

  • Create a test table

    CREATE TABLE tran_par (
        id              BIGINT
    )
    PARTITIONED BY (
        ds              STRING
    )
    TBLPROPERTIES ('transactional'='true');
  • View detailed information about the table

    DESC EXTENDED tran_par;
  • Result

    The Transactional property is displayed in Extended Info.

    +------------------------------------------------------------------------------------+
    | 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 base table for testing.
    CREATE TABLE page_view_logs (
        page_id STRING,
        user_id STRING,
        view_timestamp BIGINT
    );
    
    -- Create a materialized view to calculate the page views (PV) for 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;
  • 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 14: 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 the partition information of the partitioned table.

    DESC test_table_partition PARTITION (sale_date='201310', region='beijing');
  • 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 statements