hive建表脚本

HIVE="sudo -u hdfs hive"

db_name="chenzl"
table_name="kn1_base_conf_group"

$HIVE<< EOF
USE ${db_name};
DROP TABLE ${table_name};
CREATE EXTERNAL TABLE ${table_name}
(
day_key               date               comment'日期',
group_id               bigint               comment'组编号',
group_name               string               comment'组名称',
realgroup_id               bigint               comment'真实组编号',
realgroup_name               string               comment'真实组名称',
app_service_id               bigint               comment'应用服务编号',
app_service_name               string               comment'应用服务名称',
service_state               string               comment'服务状态',
node_id               bigint               comment'节点编号',
node_name               string               comment'节点名称',
area               string               comment'区域',
province               string               comment'省份',
isp               string               comment'运营商编码',
isp_cnname               string               comment'运营商名称',
province_name               string               comment'省份名称',
area_name               string               comment'大区'
)
COMMENT '组信息维度表'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION '/user/hive/warehouse/dw/kn1_base_conf_group';
ALTER TABLE ${table_name} SET SERDEPROPERTIES('serialization.null.format'='');
EOF