阿里云dataworks表操作

–odps sql

–author:宋文理
–create time:

创建表
创建非分区表、分区表、外部表或聚簇表。

限制条件
分区表的分区层级不能超过6级。例如某张表以日期为分区列,分区层级为年/月/周/日/时/分。
一张表允许的分区个数支持按照具体的项目配置,默认为6万个。
更多表的限制条件,请参见SQL使用限制项。

命令格式如下
–创建新表。
create [external] table [if not exists] <table_name>
[(<col_name> <data_type> [not null] [default <default_value>] [comment <col_comment>], …)]
[comment <table_comment>]
[partitioned by (<col_name> <data_type> [comment <col_comment>], …)]
–用于创建聚簇表时设置表的Shuffle和Sort属性。
[clustered by | range clustered by (<col_name> [, <col_name>, …])
[sorted by (<col_name> [asc | desc] [, <col_name> [asc | desc] …])]
into <number_of_buckets> buckets]
–仅限外部表。
[stored by StorageHandler]
–仅限外部表。
[with serdeproperties (options)]
–仅限外部表。
[location ]
–指定表为Transactional表,后续可以对该表执行更新或删除表数据操作,但是Transactional表有部分使用限制,请根据需求创建。
[tblproperties(“transactional”=“true”)]
[lifecycle ];

–基于已存在的表创建新表并复制数据,但不复制分区属性。支持外部表和湖仓一体外部项目中的表。
create table [if not exists] <table_name> [lifecycle ] as <select_statement>;

–基于已存在的表创建具备相同结构的新表但不复制数据,支持外部表和湖仓一体外部项目中的表。
create table [if not exists] <table_name> like <existing_table_name> [lifecycle ];
参数说明
external:可选。表示创建的表为外部表。
if not exists:可选。如果不指定if not exists选项而存在同名表,会报错。如果指定if not exists,只要存在同名表,
即使原表结构与要创建的目标表结构不一致,均返回成功。已存在的同名表的元数据信息不会被改动。
table_name:必填。表名。表名大小写不敏感,不能有特殊字符,只能包含az、AZ、数字和下划线()。
建议以字母开头,名称的长度不超过128字节,否则报错。
col_name:可选。表的列名。列名大小写不敏感,不能有特殊字符,只能包含az、AZ、数字、下划线(
)或中文。建议以字母开头,
名称的长度不超过128字节,否则报错。
col_comment:可选。列的注释内容。注释内容为长度不超过1024字节的有效字符串,否则报错。
data_type:可选。列的数据类型,包含BIGINT、DOUBLE、BOOLEAN、DATETIME、DECIMAL和STRING等多种数据类型,
详情请参见数据类型版本说明。
not null:可选。禁止该列的值为NULL。更多修改非空属性信息,请参见修改表的列非空属性。
default_value:可选。指定列的默认值,当insert操作不指定该列时,该列写入默认值。
table_comment:可选。表注释内容。注释内容为长度不超过1024字节的有效字符串,否则报错。
partitioned by (<col_name> <data_type> [comment <col_comment>], …:可选。指定分区表的分区字段。
col_name:表的分区列名。列名大小写不敏感,不能有特殊字符,只能包含az、AZ、数字、下划线()或中文。
建议以字母开头,名称的长度不超过128字节,否则报错。
data_type:分区列的数据类型。MaxCompute 1.0版本仅支持STRING类型。MaxCompute 2.0版本扩充了分区类型,
包含TINYINT、SMALLINT、INT、BIGINT、VARCHAR和STRING类型。详情请参见数据类型版本说明。当使用分区字段对表进行分区时,
新增分区、更新分区内数据和读取分区数据均不需要做全表扫描,提高处理效率。
col_comment:分区列的注释内容。注释内容为长度不超过1024字节的有效字符串,否则报错。
说明 分区值不能包含双字节字符(如中文),必须以字母开头,包含字母、数字和允许的字符,长度不超过128字节。
允许的字符包括空格、冒号(:)、下划线(
)、美元符号($)、井号(#)、英文句点(.)、感叹号(!)和at(@),
其他字符的行为未定义,例如转义字符 \t、 \n和 /。
clustered by | range clustered by (<col_name> [, <col_name>, …]) [sorted by (<col_name> [asc | desc] [, <col_name> [asc | desc] …])]
into <number_of_buckets> buckets:可选。
用于创建聚簇表时设置表的Shuffle和Sort属性。

– 示例1:创建非分区表test1。
create table test1 (key STRING);
– 示例2:创建一张分区表sale_detail。
create table if not exists sale_detail(
shop_name STRING,
customer_id STRING,
total_price DOUBLE)
partitioned by (sale_date STRING, region STRING);
– 示例3:创建一个新表sale_detail_ctas1,将sale_detail的数据复制到sale_detail_ctas1中,并设置生命周期。
create table sale_detail_ctas1 lifecycle 10 as select * from sale_detail;
– 此处sale_detail是一张分区表,而通过create table … as select_statement …语句创建的表sale_detail_ctas1不会复制分区属性,
– 只会把源表的分区列作为目标表的一般列处理。即sale_detail_ctas1是一个含有5列的非分区表。

– 想要从原表查询后建立分区表,应该使用clone table方法

示例4:创建一个新表sale_detail_ctas2,在select子句中使用常量作为列的值。
–指定列的名字。
create table sale_detail_ctas2
as
select shop_name, customer_id, total_price, ‘2013’ as sale_date, ‘China’ as region
from sale_detail;
–不指定列的名字。
create table sale_detail_ctas3
as
select shop_name, customer_id, total_price, ‘2013’, ‘China’
from sale_detail;
– 说明 如果在 select子句中使用常量作为列的值,建议您指定列的名字。创建的表sale_detail_ctas3的第四、五列类似于 _c4、 _c5。
– 示例5:创建一个新表sale_detail_like,与sale_detail具有相同的表结构,并设置生命周期。
create table sale_detail_like like sale_detail lifecycle 10;
您可以通过desc extended sale_detail_like;命令查看到表的结构及生命周期等详细信息。

– sale_detail_like的表结构与sale_detail完全相同。除生命周期属性外,列名、列注释以及表注释等均相同。但sale_detail中的数据不会被复制到sale_detail_like表中。

– 示例6:创建一个新表mc_oss_extable_orc_like,与外部表mc_oss_extable_orc具有相同的表结构。
create table mc_oss_extable_orc_like like mc_oss_extable_orc;
– 您可以通过 desc mc_oss_extable_orc_like;命令查看表结构等详细信息。
±-----------------------------------------------------------------------------------+
| Owner: ALIYUN$@.aliyunid.com | Project: max_compute_7u***********yoq |
| TableComment: |
±-----------------------------------------------------------------------------------+
| CreateTime: 2022-08-11 11:10:47 |
| LastDDLTime: 2022-08-11 11:10:47 |
| LastModifiedTime: 2022-08-11 11:10:47 |
±-----------------------------------------------------------------------------------+
| InternalTable: YES | Size: 0 |
±-----------------------------------------------------------------------------------+
| Native Columns: |
±-----------------------------------------------------------------------------------+
| Field | Type | Label | Comment |
±-----------------------------------------------------------------------------------+
| id | string | | |
| name | string | | |
±-----------------------------------------------------------------------------------+
– 示例7:创建使用新数据类型的表test_newtype。
set odps.sql.type.system.odps2=true;
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>
,c12 STRUCTs1:STRING,s2:BIGINT
,c13 VARCHAR(20))
LIFECYCLE 1
;
– 示例8:创建Hash聚簇非分区表t1。
create table t1 (a STRING, b STRING, c BIGINT) clustered by © sorted by © into 1024 buckets;
– 示例9:创建Hash聚簇分区表t2。
create table t2 (a STRING, b STRING, c BIGINT) partitioned by (dt STRING) clustered by © sorted by © into 1024 buckets;
– 示例10:创建Range聚簇非分区表t3。
create table t3 (a STRING, b STRING, c BIGINT) range clustered by © sorted by © into 1024 buckets;
– 示例11:创建Range聚簇分区表t4。
create table t4 (a STRING, b STRING, c BIGINT) partitioned by (dt STRING) range clustered by © sorted by ©;
– 示例12:创建Transactional非分区表t5。
create table t5(id bigint) tblproperties(“transactional”=“true”);
– 示例13:创建Transactional分区表t6。
create table if not exists t6(id bigint) partitioned by(ds string) tblproperties (“transactional”=“true”);
– 示例14:创建非分区表test_default,并为字段指定默认值。
create table test_default
(
tinyint_name tinyint not NULL default 1Y,
smallint_name SMALLINT not NULL DEFAULT 1S,
int_name INT not NULL DEFAULT 1,
bigint_name BIGINT not NULL DEFAULT 1,
binary_name BINARY ,
float_name FLOAT ,
double_name DOUBLE not NULL DEFAULT 0.1,
decimal_name DECIMAL(2, 1) not NULL DEFAULT 0.0BD,
varchar_name VARCHAR(10) ,
char_name CHAR(2) ,
string_name STRING not NULL DEFAULT ‘N’,
boolean_name BOOLEAN not NULL DEFAULT TRUE
);
– 示例15:使用create table [if not exists] <table_name> [lifecycle ] as <select_statement>;语句创建内部表复制外部分区表数据,内部表不包含分区属性。
– MaxCompute侧查询湖仓一体外部表
select * from hive_external2_1.myhive_0110;
– 结果
a b c
101 1 20230110
102 2 20230110
103 3 20230110

– 使用create table as创建内部表
create table from_exetbl_as_par as select * from hive_external2_1.myhive_0110_par;

– 查询新建内部表
select * from from_exetbl_as_par;
– 返回结果,全表数据都有
a b c
101 1 20230110
102 2 20230110
103 3 20230110

– 查询新建内部表结构
desc from_exetbl_as_par;
– 返回结果
±-----------------------------------------------------------------------------------+
| Owner: ALIYUN$*********** |
| Project: __* |
| TableComment: |
±-----------------------------------------------------------------------------------+
| CreateTime: 2023-01-10 15:16:33 |
| LastDDLTime: 2023-01-10 15:16:33 |
| LastModifiedTime: 2023-01-10 15:16:33 |
±-----------------------------------------------------------------------------------+
| InternalTable: YES | Size: 919 |
±-----------------------------------------------------------------------------------+
| Native Columns: |
±-----------------------------------------------------------------------------------+
| Field | Type | Label | Comment |
±-----------------------------------------------------------------------------------+
| a | string | | |
| b | string | | |
| c | string | | |
– ±-----------------------------------------------------------------------------------+
– 示例16:使用create table [if not exists] <table_name> like <existing_table_name> [lifecycle ];语句创建内部表复制外部分区表结构,内部表包含分区属性。
– MaxCompute侧查询湖仓一体外部表
select * from hive_external2_1.myhive_0110_par;
– 返回结果
a b c
101 1 20230110
102 2 20230110
103 3 20230110

– 使用create table like创建内部表
create table from_exetbl_like like hive_external2_1.myhive_0110_par;

– 查询新建内部表
select * from from_exetbl_like_par;
– 返回结果,只有表结构出现
a b c

– 查询内部表结构
desc from_exetbl_like;
– 返回结果
±-----------------------------------------------------------------------------------+
| Owner: ALIYUN$************ |
| Project: __* |
| TableComment: |
±-----------------------------------------------------------------------------------+
| CreateTime: 2023-01-10 15:09:47 |
| LastDDLTime: 2023-01-10 15:09:47 |
| LastModifiedTime: 2023-01-10 15:09:47 |
±-----------------------------------------------------------------------------------+
| InternalTable: YES | Size: 0 |
±-----------------------------------------------------------------------------------+
| Native Columns: |
±-----------------------------------------------------------------------------------+
| Field | Type | Label | Comment |
±-----------------------------------------------------------------------------------+
| a | string | | |
| b | string | | |
±-----------------------------------------------------------------------------------+
| Partition Columns: |
±-----------------------------------------------------------------------------------+
| c | string | |
±-----------------------------------------------------------------------------------+
修改表的所有人
修改表的所有人,即表Owner。

命令格式
alter table <table_name> changeowner to <new_owner>;
参数说明
table_name:必填。待修改Owner的表名。
new_owner:必填。修改后的Owner账号。
使用示例
–将表test1的所有人修改为ALIYUN x x x @ a l i y u n . c o m 。 a l t e r t a b l e t e s t 1 c h a n g e o w n e r t o ′ A L I Y U N xxx@aliyun.com。 alter table test1 changeowner to 'ALIYUN xxx@aliyun.comaltertabletest1changeownertoALIYUNxxx@aliyun.com’;
修改表的注释
修改表的注释内容。

命令格式
alter table <table_name> set comment ‘<new_comment>’;
参数说明
table_name:必填。待修改注释的表的名称。
new_comment:必填。修改后的注释名称。
使用示例
alter table sale_detail set comment ‘new coments for table sale_detail’;
您可以通过MaxCompute的desc table_name命令查看表中comment的修改结果。
修改表的修改时间
MaxCompute SQL提供touch操作用来修改表的LastModifiedTime,可将表的LastModifiedTime修改为当前时间。此操作会改变表的LastModifiedTime的值,
MaxCompute会认为表的数据有变动,生命周期的计算会重新开始。

命令格式
alter table <table_name> touch;
参数说明
table_name:必填。待修改表的修改时间的表名称。

使用示例
alter table sale_detail touch;
修改表的聚簇属性
对于分区表,MaxCompute支持通过alter table语句增加或者去除聚簇属性。

命令格式
增加表的Hash聚簇属性的语法格式如下:
alter table <table_name> [clustered by (<col_name> [, <col_name>, …]) [sorted by (<col_name> [asc | desc] [, <col_name> [asc | desc] …])] into <number_of_buckets> buckets];
去除表的Hash聚簇属性的语法格式如下:
alter table <table_name> not clustered;
增加表的Range聚簇属性,Bucket数不是必须的,可以省略,此时系统会根据数据量自动决定最佳的Bucket数目。语法格式如下:
alter table <table_name> [range clustered by (<col_name> [, <col_name>, …]) [sorted by (<col_name> [asc | desc] [, <col_name> [asc | desc] …])] into <number_of_buckets> buckets];
去除表或分区的Range聚簇属性的语法格式如下:
alter table <table_name> not clustered;
alter table <table_name> <pt_spec> not clustered;
说明
通过alter table改变聚簇属性,只对分区表有效,非分区表一旦建立聚簇属性就无法改变。alter table语句适用于存量表,在增加了新的聚簇属性后,新的分区将按设置的聚簇属性存储。
alter table只会影响分区表的新建分区(包括insert overwrite生成的),新分区将按新的聚簇属性存储,老数据分区的聚簇属性和存储保持不变。即在一张曾经做过聚簇属性设置的表上,
关闭了聚簇属性,再增加聚簇设置,可以在新分区设置不同于之前的聚簇列、排序列及分桶数。
由于alter table只影响新分区,所以该语句不可以再指定分区。
参数说明
详情请参见创建表。

重命名表
重命名表的名称。仅修改表的名字,不改动表中的数据。

命令格式
alter table <table_name> rename to <new_table_name>;
参数说明
table_name:必填。待修改名称的表。
new_table_name:必填。修改后的表名称。如果已存在与new_table_name同名的表,会返回报错。
使用示例
alter table sale_detail rename to sale_detail_rename;
清空非分区表里的数据
将指定的非分区表中的数据清空。如果您需要清空分区表中单个或多个分区的数据,请参见清空分区数据。

命令格式
truncate table <table_name>;
参数说明
table_name:必填。待清空数据的非分区表的名称。

删除表
删除非分区表或分区表。

注意事项
请谨慎操作,确认表可以删除后,再执行删除操作。如果误删了表,当项目开启了备份恢复功能,且删除操作未超过项目设置的备份数据保留天数时,则可以恢复表。更多备份恢复信息,请参见备份与恢复。
删除表之后,MaxCompute项目的存储量会降低。
命令格式
drop table [if exists] <table_name>;
参数说明
if exists:可选。如果不指定if exists且表不存在,则返回异常。如果指定if exists,无论表是否存在,均返回成功。
table_name:必填。待删除的表名。
使用示例
–删除表sale_detail。无论sale_detail表是否存在,均返回成功。
drop table if exists sale_detail;
查看表或视图信息
查看MaxCompute内部表、视图、外部表、聚簇表或Transactional表的信息。如果您需要查看表的详细数据信息,请参见SELECT语法。

命令格式
–查看表或视图信息。
desc <table_name|view_name> [partition (<pt_spec>)];
–查看外部表、聚簇表或Transactional表信息。也可以查看内部表的扩展信息。
desc extended <table_name>;
参数说明
table_name:必填。待查看表的名称。
view_name:必填。待查看视图的名称。
pt_spec:可选。待查看分区表的指定分区。格式为(partition_col1 = partition_col_value1, partition_col2 = partition_col_value2, …)。
extended:如果表为外部表、聚簇表或Transactional表,需要包含此参数。显示表的扩展信息。也可以查看内部表的扩展信息,例如列的非空属性。
使用示例
示例1:查看创建的test1表的信息。
desc test1;
返回结果如下。
±-----------------------------------------------------------------------------------+
| Owner: ALIYUN$maoXXX@alibaba-inc.com | Project: p r o j e c t n a m e ∣ ∣ T a b l e C o m m e n t : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ C r e a t e T i m e : 2020 − 11 − 1617 : 47 : 48 ∣ ∣ L a s t D D L T i m e : 2020 − 11 − 1617 : 47 : 48 ∣ ∣ L a s t M o d i f i e d T i m e : 2020 − 11 − 1617 : 47 : 48 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ I n t e r n a l T a b l e : Y E S ∣ S i z e : 0 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ N a t i v e C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ F i e l d ∣ T y p e ∣ L a b e l ∣ C o m m e n t ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ k e y ∣ s t r i n g ∣ ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + 示例 2 :查看创建的 s a l e d e t a i l 表的信息。 d e s c s a l e d e t a i l ; 返回结果如下。 + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ O w n e r : A L I Y U N 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 | | | +------------------------------------------------------------------------------------+ 示例2:查看创建的sale_detail表的信息。 desc sale_detail; 返回结果如下。 +--------------------------------------------------------------------+ | Owner: ALIYUN projectname∣∣TableComment:++CreateTime:2020111617:47:48∣∣LastDDLTime:2020111617:47:48∣∣LastModifiedTime:2020111617:47:48∣++InternalTable:YESSize:0∣++NativeColumns:++FieldTypeLabelComment++keystring∣∣∣++示例2:查看创建的saledetail表的信息。descsaledetail;返回结果如下。++Owner:ALIYUNmaoXXX@alibaba-inc.com | Project: p r o j e c t n a m e ∣ ∣ T a b l e C o m m e n t : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ C r e a t e T i m e : 2017 − 06 − 2815 : 05 : 17 ∣ ∣ L a s t D D L T i m e : 2017 − 06 − 2815 : 05 : 17 ∣ ∣ L a s t M o d i f i e d T i m e : 2017 − 06 − 2815 : 05 : 17 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ I n t e r n a l T a b l e : Y E S ∣ S i z e : 0 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ N a t i v e C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ F i e l d ∣ T y p e ∣ L a b e l ∣ C o m m e n t ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ s h o p n a m e ∣ s t r i n g ∣ ∣ ∣ ∣ c u s t o m e r i d ∣ s t r i n g ∣ ∣ ∣ ∣ t o t a l p r i c e ∣ d o u b l e ∣ ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ P a r t i t i o n C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ s a l e d a t e ∣ s t r i n g ∣ ∣ ∣ r e g i o n ∣ s t r i n g ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + 示例 3 :查看创建的 s a l e d e t a i l c t a s 1 表的详细信息。 d e s c e x t e n d e d s a l e d e t a i l c t a s 1 ; 返回结果如下。 + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ O w n e r : A L I Y U N 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 | | +--------------------------------------------------------------------+ 示例3:查看创建的sale_detail_ctas1表的详细信息。 desc extended sale_detail_ctas1; 返回结果如下。 +------------------------------------------------------------------------------------+ | Owner: ALIYUN projectname∣∣TableComment:++CreateTime:2017062815:05:17∣∣LastDDLTime:2017062815:05:17∣∣LastModifiedTime:2017062815:05:17∣++InternalTable:YESSize:0∣++NativeColumns:++FieldTypeLabelComment++shopnamestring∣∣∣∣customeridstring∣∣∣∣totalpricedouble∣∣∣++PartitionColumns:++saledatestring∣∣∣regionstring∣∣++示例3:查看创建的saledetailctas1表的详细信息。descextendedsaledetailctas1;返回结果如下。++Owner:ALIYUNmaoXXX@alibaba-inc.com | Project: p r o j e c t n a m e ∣ ∣ T a b l e C o m m e n t : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ C r e a t e T i m e : 2021 − 07 − 0715 : 29 : 53 ∣ ∣ L a s t D D L T i m e : 2021 − 07 − 0715 : 29 : 53 ∣ ∣ L a s t M o d i f i e d T i m e : 2021 − 07 − 0715 : 29 : 53 ∣ ∣ L i f e c y c l e : 10 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ I n t e r n a l T a b l e : Y E S ∣ S i z e : 0 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ N a t i v e C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ F i e l d ∣ T y p e ∣ L a b e l ∣ E x t e n d e d L a b e l ∣ N u l l a b l e ∣ D e f a u l t V a l u e ∣ C o m m e n t ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ s h o p n a m e ∣ s t r i n g ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ ∣ c u s t o m e r i d ∣ s t r i n g ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ ∣ t o t a l p r i c e ∣ d o u b l e ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ ∣ s a l e d a t e ∣ s t r i n g ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ ∣ r e g i o n ∣ s t r i n g ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ E x t e n d e d I n f o : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ T a b l e I D : 98 c b 8 a 38733 c 49 e a b e d 4735173818147 ∣ ∣ I s A r c h i v e d : f a l s e ∣ ∣ P h y s i c a l S i z e : 0 ∣ ∣ F i l e N u m : 0 ∣ ∣ S t o r e d A s : A l i O r c ∣ ∣ C o m p r e s s i o n S t r a t e g y : n o r m a l ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + s a l e d a t e 和 r e g i o n 两个字段仅会作为普通列存在,而不是表的分区。示例 4 :查看创建的 s a l e d e t a i l c t a s 2 表的信息。 d e s c s a l e d e t a i l c t a s 2 ; 返回结果如下。 + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ O w n e r : A L I Y U N 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 | +------------------------------------------------------------------------------------+ sale_date和region两个字段仅会作为普通列存在,而不是表的分区。 示例4:查看创建的sale_detail_ctas2表的信息。 desc sale_detail_ctas2; 返回结果如下。 +--------------------------------------------------------------------+ | Owner: ALIYUN projectname∣∣TableComment:++CreateTime:2021070715:29:53∣∣LastDDLTime:2021070715:29:53∣∣LastModifiedTime:2021070715:29:53∣∣Lifecycle:10∣++InternalTable:YESSize:0∣++NativeColumns:++FieldTypeLabelExtendedLabelNullableDefaultValueComment++shopnamestring∣∣∣trueNULL∣∣∣customeridstring∣∣∣trueNULL∣∣∣totalpricedouble∣∣∣trueNULL∣∣∣saledatestring∣∣∣trueNULL∣∣∣regionstring∣∣∣trueNULL∣∣++ExtendedInfo:++TableID:98cb8a38733c49eabed4735173818147∣∣IsArchived:false∣∣PhysicalSize:0∣∣FileNum:0∣∣StoredAs:AliOrc∣∣CompressionStrategy:normal++saledateregion两个字段仅会作为普通列存在,而不是表的分区。示例4:查看创建的saledetailctas2表的信息。descsaledetailctas2;返回结果如下。++Owner:ALIYUNxxxxx@alibaba-inc.com | Project: p r o j e c t n a m e ∣ ∣ T a b l e C o m m e n t : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ C r e a t e T i m e : 2017 − 06 − 2815 : 42 : 17 ∣ ∣ L a s t D D L T i m e : 2017 − 06 − 2815 : 42 : 17 ∣ ∣ L a s t M o d i f i e d T i m e : 2017 − 06 − 2815 : 42 : 17 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ I n t e r n a l T a b l e : Y E S ∣ S i z e : 0 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ N a t i v e C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ F i e l d ∣ T y p e ∣ L a b e l ∣ C o m m e n t ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ s h o p n a m e ∣ s t r i n g ∣ ∣ ∣ ∣ c u s t o m e r i d ∣ s t r i n g ∣ ∣ ∣ ∣ t o t a l p r i c e ∣ d o u b l e ∣ ∣ ∣ ∣ s a l e d a t e ∣ s t r i n g ∣ ∣ ∣ ∣ r e g i o n ∣ s t r i n g ∣ ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + 示例 5 :查看创建的 s a l e d e t a i l l i k e 表的详细信息。 d e s c e x t e n d e d s a l e d e t a i l l i k e ; 返回结果如下。 + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ O w n e r : A L I Y U N 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 | | | +--------------------------------------------------------------------+ 示例5:查看创建的sale_detail_like表的详细信息。 desc extended sale_detail_like; 返回结果如下。 +------------------------------------------------------------------------------------+ | Owner: ALIYUN projectname∣∣TableComment:++CreateTime:2017062815:42:17∣∣LastDDLTime:2017062815:42:17∣∣LastModifiedTime:2017062815:42:17∣++InternalTable:YESSize:0∣++NativeColumns:++FieldTypeLabelComment++shopnamestring∣∣∣∣customeridstring∣∣∣∣totalpricedouble∣∣∣∣saledatestring∣∣∣∣regionstring∣∣∣++示例5:查看创建的saledetaillike表的详细信息。descextendedsaledetaillike;返回结果如下。++Owner:ALIYUNxxxxx@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 |
±-----------------------------------------------------------------------------------+
除生命周期属性外,sale_detail_like的其它属性(字段类型、分区类型等)均与sale_detail完全一致。
说明 通过 desc table_name查看到的Size包含了在回收站的数据Size。如果您需要清空回收站,可以先执行 purge table table_name,然后再
执行 desc table_name查看除回收站以外的数据大小。您也可以执行 show recyclebin查看本项目中回收站内的数据明细。
示例6:查看创建的test_newtype表的信息。
desc test_newtype;
返回结果如下。
| 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> | | |
| c12 | structs1:string,s2:bigint | | |
| c13 | varchar(20) | | |
±-----------------------------------------------------------------------------------+

OK
示例7:查看创建的Hash聚簇非分区表t1的信息。聚簇属性将显示在Extended Info中。
desc extended t1;
返回结果如下。
±-----------------------------------------------------------------------------------+
| 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
示例8:查看创建的Hash聚簇分区表t2的信息。聚簇属性将显示在Extended Info中。
desc extended t2;
返回结果如下。
±-----------------------------------------------------------------------------------+
| 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
示例9:查看Range聚簇非分区表t3的信息。聚簇属性将显示在Extended Info中。
desc extended t3;
返回结果如下。
±-----------------------------------------------------------------------------------+
| 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
示例10:查看Range聚簇分区表t4的信息。聚簇属性将显示在Extended Info中。
desc extended t4;
返回结果如下。
±-----------------------------------------------------------------------------------+
| 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
示例11:查看非分区表t5是否为Transactional表。
说明 推荐您使用 MaxCompute客户端查看表是否为Transactional表,需要将MaxCompute客户端升级到0.35.4版本。其他工具可能会存在版本升级未就绪的问题,
导致查询结果不显示Transactional信息。
desc extended t5;
返回结果如下。
±-----------------------------------------------------------------------------------+
| Owner: ALIYUN$xxxxx@aliyun.com | Project: p r o j e c t n a m e ∣ ∣ T a b l e C o m m e n t : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ C r e a t e T i m e : 2021 − 02 − 1810 : 56 : 27 ∣ ∣ L a s t D D L T i m e : 2021 − 02 − 1810 : 56 : 27 ∣ ∣ L a s t M o d i f i e d T i m e : 2021 − 02 − 1810 : 56 : 27 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ I n t e r n a l T a b l e : Y E S ∣ S i z e : 0 ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ N a t i v e C o l u m n s : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ F i e l d ∣ T y p e ∣ L a b e l ∣ E x t e n d e d L a b e l ∣ N u l l a b l e ∣ D e f a u l t V a l u e ∣ C o m m e n t ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ i d ∣ b i g i n t ∣ ∣ ∣ t r u e ∣ N U L L ∣ ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ E x t e n d e d I n f o : ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + . . . ∣ T r a n s a c t i o n a l : t r u e ∣ + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + 示例 12 :查看分区表 t 6 是否为 T r a n s a c t i o n a l 表。说明推荐您使用 M a x C o m p u t e 客户端查看表是否为 T r a n s a c t i o n a l 表,需要将 M a x C o m p u t e 客户端升级到 0.35.4 版本。其他工具可能会存在版本升级未就绪的问题,导致查询结果不显示 T r a n s a c t i o n a l 信息。 d e s c e x t e n d e d t 6 ; 返回结果如下。 + − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − + ∣ O w n e r : A L I Y U N 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 | +------------------------------------------------------------------------------------+ 示例12:查看分区表t6是否为Transactional表。 说明 推荐您使用 MaxCompute客户端查看表是否为Transactional表,需要将MaxCompute客户端升级到0.35.4版本。其他工具可能会存在版本升级未就绪的问题, 导致查询结果不显示Transactional信息。 desc extended t6; 返回结果如下。 +------------------------------------------------------------------------------------+ | Owner: ALIYUN projectname∣∣TableComment:++CreateTime:2021021810:56:27∣∣LastDDLTime:2021021810:56:27∣∣LastModifiedTime:2021021810:56:27∣++InternalTable:YESSize:0∣++NativeColumns:++FieldTypeLabelExtendedLabelNullableDefaultValueComment++idbigint∣∣∣trueNULL∣∣++ExtendedInfo:++...∣Transactional:true++示例12:查看分区表t6是否为Transactional表。说明推荐您使用MaxCompute客户端查看表是否为Transactional表,需要将MaxCompute客户端升级到0.35.4版本。其他工具可能会存在版本升级未就绪的问题,导致查询结果不显示Transactional信息。descextendedt6;返回结果如下。++Owner:ALIYUNxxxxx@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 |
±-----------------------------------------------------------------------------------+
查看分区信息
查看某个分区表具体的分区的信息。

命令格式
desc <table_name> partition (<pt_spec>);
参数说明
table_name:必填。待查看分区信息的分区表名称。
pt_spec:必填。待查看的分区信息。格式为partition_col1=col1_value1, partition_col2=col2_value1…。对于有多级分区的表,必须指明全部的分区值。
使用示例
–查询分区表sale_detail的分区信息。
desc sale_detail partition (sale_date=‘201310’,region=‘beijing’);
返回结果如下。
±-----------------------------------------------------------------------------------+
| PartitionSize: 2109112 |
±-----------------------------------------------------------------------------------+
| CreateTime: 2015-10-10 08:48:48 |
| LastDDLTime: 2015-10-10 08:48:48 |
| LastModifiedTime: 2015-10-11 01:33:35 |
±-----------------------------------------------------------------------------------+
OK
查看建表语句
生成创建表的SQL DDL语句,方便您通过SQL重建Schema。

命令格式
show create table <table_name>;
参数说明
table_name:必填。待查看建表语句的表的名称。

使用示例
–查看表sale_detail的建表语句。
show create table sale_detail;
返回结果如下。
CREATE TABLE IF NOT EXISTS doc_test_dev.sale_detail(shop_name STRING,customer_id STRING,total_price DOUBLE) PARTITIONED BY (sale_date STRING,region STRING)
STORED AS ALIORC;
列出项目下的表和视图
列出项目下所有的表和视图,或符合某规则的表和视图。

命令格式
–列出项目下所有的表和视图。
show tables;
–列出项目下表名或视图名与chart匹配的表。
show tables like ‘’;
使用示例
–列出项目下表名与sale*匹配的表。表示任意字段。
show tables like 'sale
’;
返回结果如下。
ALIYUN$account_name:sale_detail

–ALIYUN是系统提示符,表示您是阿里云主账号用户。如果您是阿里云RAM用户,系统提示符为RAM。
列出所有分区
列出一张表中的所有分区,表不存在或为非分区表时,返回报错。

命令格式
show partitions <table_name>;
参数说明
table_name:必填。待查看分区信息的分区表名称。

使用示例
–列出sale_detail中的所有分区。
show partitions sale_detail;
返回结果如下。
sale_date=201310/region=beijing
sale_date=201312/region=shenzhen
sale_date=201312/region=xian
sale_date=2014/region=shenzhen

OK

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大数据小理

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值