1.创建分区表
create table <table_name> [(<col_name> <data_type> [comment <col_comment>], ...)] [comment <table_comment>] [partition by (<col_name> <data_type> [comment <col_comment>], ...)]
- table_name:必填。表名。表名大小写不敏感,不能有特殊字符,只能包含a~z、A~Z、数字和下划线(_)。建议以字母开头,名称的长度不超过128字节,否则报错。
- data_type:可选。列的数据类型
- col_comment:可选。列的注释内容。注释内容为长度不超过1024字节的有效字符串,否则报错。
- table_comment:可选。表注释内容。注释内容为长度不超过1024字节的有效字符串,否则报错。
- partitioned by (<col_name> <data_type> [comment <col_comment>], ...:可选。指定分区表的分区字段。
例:create table order_name_null
(
col_a bigint comment '序号'
,col_name string comment '类目名称'
,cal_city_name string comment '城市名称'
,dt string comment '日期'
)
comment '订单信息表'
partition by (
dt string comment '99999999:黑名单数据,其它:yyyymmdd,日新增'
);
2.修改表描述
ALTER TABLE <table_name> SET TBLPROPERTIES('comment' = '*********************');
例:ALTER TABLE order_name_null SET TBLPROPERTIES('comment' = '城市维度订单表');
3.插入数据
insert overwrite table <table_name> values(...)
注意: inster into :追加数据 insert overwrite :覆盖数据
例:insert overwrite table order_name_null values (1,'玉米','南京','20221214'),(1,'小麦','北京','20221216'),(1,'大豆','天津','20221217'),(1,'大米','重庆','20221218');
4.删除表
DROP TABLE <table_name>;
例:DROP TABLE order_name_null;
5.删除特定数据
delete from <table_name> where <where_condition>;
- table_name:必填。待执行
delete操作的Transactional表名称。 - where_condition:可选。WHERE子句,用于筛选满足条件的数据
例:delete from order_name_null where dt = 20221218 and cal_city_name = '南京';
716

被折叠的 条评论
为什么被折叠?



