赞
踩
1.建立表语句信息
--EXTERNAL 备份表不建立外表
CREATE EXTERNAL TABLE IF NOT EXISTS itcast_ods.web_chat_ems_bak (
id INT comment '主键',
create_date_time STRING comment '数据创建时间',
session_id STRING comment '七陌sessionId',
sid STRING comment '访客id',
create_time STRING comment '会话创建时间',
seo_source STRING comment '搜索来源',
seo_keywords STRING comment '关键字',
ip STRING comment 'IP地址',
area STRING comment '地域',
country STRING comment '所在国家',
province STRING comment '省',
city STRING comment '城市',
origin_channel STRING comment '投放渠道',
user_match STRING comment '所属坐席',
manual_time STRING comment '人工开始时间',
begin_time STRING comment '坐席领取时间 ',
end_time STRING comment '会话结束时间',
last_customer_msg_time_stamp STRING comment '客户最后一条消息的时间',
last_agent_msg_time_stamp STRING comment '坐席最后一下回复的时间',
reply_msg_count INT comment '客服回复消息数',
msg_count INT comment '客户发送消息数',
browser_name STRING comment '浏览器名称',
os_info STRING comment '系统名称')
comment '访问会话信息表'
PARTITIONED BY(starts_time STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
stored as orc
location '/user/hive/warehouse/itcast_ods.db/web_chat_ems_ods'
TBLPROPERTIES ('orc.compress'='ZLIB');
--starts_time 建模分析的时候代表的是抽取时间
2.
外表不能被执行 truncate
方式1:将外部表文件所在目录指定成一个空的目录
alter table test_external set location 'hdfs://bd227:8020/opt/hive/warehouse/test_external_like';
方案2: 先设置成内部表属性 再执行truncate 最后把属性再修改成外表
alter table itcast_ods.web_chat_ems_bak set TBLPROPERTIES('EXTERNAL'='false');
truncate table itcast_ods.web_chat_ems_bak;
alter table itcast_ods.web_chat_ems_bak set TBLPROPERTIES('EXTERNAL'='true');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。