Affiche les informations relatives aux tables internes, vues, vues matérialisées, tables externes, tables clusterisées ou tables transactionnelles MaxCompute.
Syntaxe
-- Basic: internal table or view, with optional partition filter
DESC <table_name | view_name> [PARTITION (<pt_spec>)];
-- Extended: materialized view, foreign table, clustered table, transactional table,
-- or extended information for an internal table
DESC EXTENDED <table_name | mv_name>;
Utilisez DESC pour obtenir un aperçu rapide du schéma d'une table interne ou d'une vue. Ajoutez le mot-clé EXTENDED pour récupérer des propriétés de stockage et de cluster supplémentaires, ou pour consulter les métadonnées par colonne, telles que la nullabilité et les valeurs par défaut.
Paramètres
|
Paramètre |
Obligatoire |
Description |
|
|
Oui |
Nom de la table à inspecter. |
|
|
Oui |
Nom de la vue à inspecter. |
|
|
— |
Nom de la vue matérialisée à inspecter. Utilisé avec |
|
|
Non |
Filtre de partition pour les tables partitionnées. Format : |
|
|
— |
Renvoie des informations étendues : nullabilité et valeurs par défaut par colonne pour les tables internes, ainsi que les propriétés de cluster, de stockage et de transaction pour les autres types de tables. |
Valeurs renvoyées
Champs standard
|
Champ |
Description |
|
|
Compte du propriétaire de la table ou de la vue. |
|
|
Projet MaxCompute auquel appartient la table ou la vue. |
|
|
Commentaire associé à la table ou à la vue. |
|
|
Date et heure de création de la table ou de la vue. |
|
|
Date et heure de la dernière modification du langage de définition de données (DDL) de la table ou de la vue. |
|
|
Date et heure de la dernière modification des données dans la table ou la vue. |
|
|
Date et heure approximatives du dernier accès aux données. Précision de 24 heures. Si les données sont fréquemment consultées, cette valeur n'est mise à jour qu'une fois toutes les 24 heures afin de réduire l'impact sur les performances. |
|
|
Durée de vie en jours. Renvoyé uniquement si une durée de vie est définie pour la table. |
|
|
Indique si l'objet est une table interne. Renvoyé uniquement pour les objets de type table. |
|
|
Indique si l'objet est une vue. Renvoyé uniquement pour les objets de type vue. |
|
|
Taille de la table en octets. Inclut les données actuellement présentes dans la corbeille. |
|
|
Définitions des colonnes de la table ou de la vue. |
|
|
Définitions des colonnes de clé de partition. Renvoyé uniquement pour les tables partitionnées. |
Champs étendus (DESC EXTENDED uniquement)
La commande DESC EXTENDED renvoie des champs supplémentaires selon le type de table.
Vues matérialisées
|
Champ |
Description |
|
|
Indique si l'objet est une vue matérialisée. |
|
|
Requête SQL définissant la vue matérialisée. |
|
|
Indique si la réécriture de requête est activée pour la vue matérialisée. |
|
|
Indique si l'actualisation automatique est activée. |
|
|
Indique si les données de la vue matérialisée sont obsolètes. |
Tables clusterisées
Les propriétés de cluster apparaissent dans la section Extended Info :
|
Champ |
Description |
|
|
Type de cluster : |
|
|
Nombre de buckets pour les tables clusterisées par hachage. |
|
|
Colonnes utilisées pour le clustering. |
|
|
Colonnes utilisées pour le tri au sein de chaque bucket (cluster par hachage uniquement). |
Tables transactionnelles
|
Champ |
Description |
|
|
Indique si la table est une table transactionnelle. |
|
|
Niveau d'isolation minimal. Par exemple, |
Champs de stockage
|
Champ |
Description |
|
|
ID unique de la table. |
|
|
Indique si la table est archivée. |
|
|
Taille physique de stockage en octets. |
|
|
Nombre de fichiers dans la table. |
|
|
Format de stockage, tel que |
|
|
Stratégie de compression appliquée à la table. |
|
|
Nombre de jours de conservation des données pour la fonctionnalité Time Travel. |
|
|
Statut du stockage froid. |
|
|
Niveau de stockage, tel que |
|
|
Date et heure de la dernière modification du niveau de stockage. |
|
|
Indique si le chiffrement est activé. |
Notes d'utilisation
Le champ
Sizedans la sortie deDESCinclut les données actuellement présentes dans la corbeille. Pour obtenir la taille hors corbeille, exécutez d'abordPURGE TABLE <table_name>, puisDESC <table_name>.Pour inspecter le contenu de la corbeille du projet actuel, exécutez
SHOW recyclebin.Pour vérifier si une table est transactionnelle, utilisez le client MaxCompute version 0.35.4 ou ultérieure. Les autres outils non mis à niveau vers la version requise peuvent omettre les informations transactionnelles de la sortie.
Exemples
Afficher une table non partitionnée
Créez une table et inspectez-la :
CREATE TABLE test_table (
key STRING
);
DESC test_table;
Sortie :
+------------------------------------------------------------------------------------+
| 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 | | |
+------------------------------------------------------------------------------------+
Afficher une table partitionnée
CREATE TABLE test_table_partition (
shop_name STRING,
customer_id STRING,
total_price DOUBLE
)
PARTITIONED BY (
sale_date STRING,
region STRING
);
DESC test_table_partition;
Sortie :
+------------------------------------------------------------------------------------+
| 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 | |
+------------------------------------------------------------------------------------+
Afficher les informations étendues pour une table partitionnée
La commande DESC EXTENDED ajoute la nullabilité et les valeurs par défaut par colonne, ainsi que la section Extended Info contenant les métadonnées de stockage :
CREATE TABLE IF NOT EXISTS test_table_partition (
shop_name STRING,
customer_id STRING,
total_price DOUBLE
)
PARTITIONED BY (
sale_date STRING,
region STRING
);
DESC EXTENDED test_table_partition;
Sortie :
+------------------------------------------------------------------------------------+
| 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 |
+------------------------------------------------------------------------------------+
Afficher une table avec une durée de vie
CREATE TABLE sale_detail_ctas(
shop_name STRING,
customer_id STRING,
total_price DOUBLE,
sale_date STRING,
region STRING
)
LIFECYCLE 10;
DESC EXTENDED sale_detail_ctas;
La sortie inclut Lifecycle: 10 dans la section d'en-tête :
+------------------------------------------------------------------------------------+
| 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 |
+------------------------------------------------------------------------------------+
Afficher une table avec des types de données complexes
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)
);
DESC test_newtype;
Sortie :
+------------------------------------------------------------------------------------+
| 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) | | |
+------------------------------------------------------------------------------------+
Afficher une table non partitionnée clusterisée par hachage
Les propriétés de cluster apparaissent dans la section Extended Info :
CREATE TABLE hash_clustered_nonpar (
a STRING,
b STRING,
c BIGINT
)
CLUSTERED BY (c)
SORTED BY (c ASC)
INTO 1024 BUCKETS;
DESC EXTENDED hash_clustered_nonpar;
Sortie :
+------------------------------------------------------------------------------------+
| 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 |
+------------------------------------------------------------------------------------+
Afficher une table partitionnée clusterisée par hachage
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;
DESC EXTENDED hash_clustered_par;
Sortie :
+------------------------------------------------------------------------------------+
| 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] |
+------------------------------------------------------------------------------------+
Afficher une table non partitionnée clusterisée par plage
CREATE TABLE range_clustered_nonpar (
a STRING,
b STRING,
c BIGINT
)
RANGE CLUSTERED BY (c);
DESC EXTENDED range_clustered_nonpar;
Sortie :
+------------------------------------------------------------------------------------+
| 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 |
+------------------------------------------------------------------------------------+
Afficher une table partitionnée clusterisée par plage
CREATE TABLE range_clustered_par (
a STRING,
b STRING,
c BIGINT
)
PARTITIONED BY (
dt STRING
)
RANGE CLUSTERED BY (c);
DESC EXTENDED range_clustered_par;
Sortie :
+------------------------------------------------------------------------------------+
| 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] |
+------------------------------------------------------------------------------------+
Vérifier si une table non partitionnée est une table transactionnelle
Utilisez le client MaxCompute version 0.35.4 ou ultérieure. Les autres outils non mis à niveau vers la version requise peuvent omettre les informations transactionnelles de la sortie.
CREATE TABLE tran_nonpar (
id BIGINT
)
TBLPROPERTIES ('transactional'='true');
DESC EXTENDED tran_nonpar;
La propriété Transactional apparaît dans la section 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 |
+------------------------------------------------------------------------------------+
Vérifier si une table partitionnée est une table transactionnelle
Utilisez le client MaxCompute version 0.35.4 ou ultérieure. Les autres outils non mis à niveau vers la version requise peuvent omettre les informations transactionnelles de la sortie.
CREATE TABLE tran_par (
id BIGINT
)
PARTITIONED BY (
ds STRING
)
TBLPROPERTIES ('transactional'='true');
DESC EXTENDED tran_par;
La propriété Transactional apparaît dans la section 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 |
+------------------------------------------------------------------------------------+
Afficher une vue matérialisée
-- Create a base table.
CREATE TABLE page_view_logs (
page_id STRING,
user_id STRING,
view_timestamp BIGINT
);
-- Create a materialized view that aggregates page views per page.
CREATE MATERIALIZED VIEW mv AS
SELECT
page_id,
COUNT(1) AS pv_count
FROM
page_view_logs
GROUP BY
page_id;
DESC EXTENDED mv;
Sortie :
+------------------------------------------------------------------------------------+
| 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 |
+------------------------------------------------------------------------------------+
Interroger les informations de partition
-- Create a partitioned 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
);
-- Add a partition and insert data.
ALTER TABLE test_table_partition ADD IF NOT EXISTS
PARTITION (sale_date='201310', region='beijing');
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.
DESC test_table_partition PARTITION (sale_date='201310', region='beijing');
Sortie :
+------------------------------------------------------------------------------------+
| PartitionSize: 1163 |
+------------------------------------------------------------------------------------+
| CreateTime: 2025-12-15 16:54:16 |
| LastDDLTime: 2025-12-15 16:54:16 |
| LastModifiedTime: 2025-12-15 16:54:23 |
+------------------------------------------------------------------------------------+
Commandes associées
CREATE TABLE : Créez une table non partitionnée, une table partitionnée, une table externe ou une table clusterisée.
CREATE VIEW : Créez une vue ou mettez à jour une vue existante basée sur une instruction de requête.
CREATE MATERIALIZED VIEW : Créez une vue matérialisée avec partitionnement et clustering facultatifs.
ALTER MATERIALIZED VIEW : Mettez à jour une vue matérialisée, modifiez sa durée de vie ou supprimez ses partitions.
Select materialized view : Interrogez le statut d'une vue matérialisée.
DROP MATERIALIZED VIEW : Supprimez une vue matérialisée.