• hive 以like方式建表(携带表结构)


    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;
    小小测试一枚
  • 相关阅读:
    方式方法和思维技巧集合
    【NOIP/CSP2019】D2T1 Emiya 家今天的饭
    【NOIP/CSP2019】D1T2 括号树
    【网络流24】餐巾
    【NOIP2016】愤怒的小鸟
    结论和典例集合
    2020牛客寒假集训营第一场题解
    新生训练赛001题解
    The 2014 ACM-ICPC Asia Regional Contest Xi'an Site题解
    SDNU ACM-ICPC 2019 Competition For the End of Term(12-15)山师停训赛题解
  • 原文地址:https://www.cnblogs.com/txdblog/p/15210332.html
Copyright © 2020-2023  润新知