1:假设仓库的ads中有一张表a,我想在ods层建一张和表a的表结构一样的表b 2.create table ods.b row format delimited fields terminated by ‘\001’ stored as parquet as select * from ads.a where 1=2; 3.优点: 快速,不需要手动创建,字段类型一样,可以修改分隔符个存储格式 4.缺点: 创建目标表的时候不支持分区 5.解决方案–自己写脚本建表
table_name=$1
target_table_name=$2
kinit -kt /hive.keytab hive
hive -e "show create table ${table_name}" > /${table_name}.txt
sed -i '1d' /${table_name}.txt
column=cat ${table_name}.txt |grep \` |awk -F' ' '{print $1 ","}'|sed '$s/.$//'
hive -e "drop table if exists ${target_table_name};
create table ${target_table_name} "(
${column}
)comment '${target_table_name}表'
partitioned by (par String)
row format delimited fields terminated by '\001'
stored as parquet
"
|