hive建表语句:
CREATE TABLE `hive_ttt_999`(
`id` bigint COMMENT 'ID,主键',
`name` string COMMENT '姓名',
`address` string COMMENT '地址',
`mobile` string COMMENT '手机号',
`other_info` string COMMENT '其他信息',
`tenant_id` string COMMENT '租户ID',
`created_by` string COMMENT '创建者',
`created_time` string COMMENT '创建时间',
`updated_time` string COMMENT '更新时间',
`updated_by` string COMMENT '更新者',
`version` bigint COMMENT '版本号,乐观锁',
`is_deleted` bigint COMMENT '是否删除')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'='|',
'serialization.format'='|')
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://nameservice1/user/hive/warehouse/ttt.db/hive_ttt_999'
TBLPROPERTIES (
'transient_lastDdlTime'='1629364931')
创建表:(以hive_ttt_999为模板)
use ttt;
create table burrowsTest_0 like hive_ttt_999;
用此脚本实现批量打印所需建表/删表语句
num = 3200
target_table = 'dct_test_from'
for x in range(800, num):
print(f'create table hive_ttt_{x} like {target_table};')
#print(f'drop table hive_ttt_{x};')
#print(f"create index hive_ttt_index_{x} on table hive_ttt_{x}(id) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild;")
给hive表建索引
create index index_01 on table hive_ttt_999(id) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild;