hive建表语句(包括txt、Orc和分区)
2017-12-12 10:53
399 查看
--------------------------------
txt格式 无分区
-------------------------------
use sx_360_safe;
create table sx_360_safe.sx_ela_bp_info
(
id_ela_bp_info string
,code string
,agent_no string
,operation_time string
,product_no string
,info_no string
,created_by string
,created_date string
,updated_by string
,updated_date string
,openid string
,page string
)
row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile;
----delimited fields terminated by '\t' 通过'\t'分割字段
----lines terminated by '\n' 通过'\n'结束一行字段
---------------------------------
Orc格式 无分区
--------------------------------
use sx_360_safe;
create table sx_360_safe.dim_olp_bank_table_grade_l
(
branch_grade decimal(38,0) ,
branch0_code string ,
branch0_name string ,
branch1_code string ,
branch1_name string ,
branch2_code string ,
branch2_name string ,
branch3_code string ,
branch3_name string ,
branch4_code string ,
branch4_name string ,
branch5_code string ,
branch5_name string ,
branch6_code string ,
branch6_name string
)
stored as orcfile;
---------------------------------
有分区的hive表
-------------------------------
use sx_360_safe;
drop table sx_360_safe.life_mbi_epics_info_yb;
create table sx_360_safe.life_mbi_epics_info_yb
(
DEPTNO string,
POLNO string,
PLAN_CODE string,
PAYMENT_DATE string,
TOT_MODAL_PREM string,
REGION_CODE string,
AMT_TYPE string,
PREM_TYPE string,
BUSINESS_TYPE string,
BUSINESS_SRC string,
OP_TYPE string,
POL_YR string,
LCD string,
FCD string,
PK_SERIAL string,
bank_channel_type string
)
PARTITIONED BY ( `day` string)
stored as orcfile;
insert ove
create table sx_360_safe.life_mbi_epics_info_yb1
(
DEPTNO string,
POLNO string,
PLAN_CODE string,
PAYMENT_DATE string,
TOT_MODAL_PREM string,
REGION_CODE string,
AMT_TYPE string,
PREM_TYPE string,
BUSINESS_TYPE string,
BUSINESS_SRC string,
OP_TYPE string,
POL_YR string,
LCD string,
FCD string,
PK_SERIAL string,
bank_channel_type string
)
PARTITIONED BY ( `day` string)
stored as orcfile;
use sx_360_safe;
set mapred.job.queue.name=queue_0101_01;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode = 1000;
set hive.exec.max.dynamic.partitions=1000;
insert overwrite table sx_360_safe.life_mbi_epics_info_yb
partition(day)
select * from sx_360_safe.life_mbi_epics_info_yb1
insert overwrite table sx_360_safe.bas_ela_agent_info
partition(day)
select
id
,code
,parent_code
,type
,type_no
,type_name
,channel
,agent
,openid
,created_date as share_read_time
,referer
,share_source
,share_channel
,detail_no
,wxbind
,substr(created_date,1,10) as statis_date
from sx_360_safe.sx_lvl_trace_info where substr(created_date,1,10) <'2017-01-01' and substr(created_date,1,10) <'2017-09-28' ;
txt格式 无分区
-------------------------------
use sx_360_safe;
create table sx_360_safe.sx_ela_bp_info
(
id_ela_bp_info string
,code string
,agent_no string
,operation_time string
,product_no string
,info_no string
,created_by string
,created_date string
,updated_by string
,updated_date string
,openid string
,page string
)
row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile;
----delimited fields terminated by '\t' 通过'\t'分割字段
----lines terminated by '\n' 通过'\n'结束一行字段
---------------------------------
Orc格式 无分区
--------------------------------
use sx_360_safe;
create table sx_360_safe.dim_olp_bank_table_grade_l
(
branch_grade decimal(38,0) ,
branch0_code string ,
branch0_name string ,
branch1_code string ,
branch1_name string ,
branch2_code string ,
branch2_name string ,
branch3_code string ,
branch3_name string ,
branch4_code string ,
branch4_name string ,
branch5_code string ,
branch5_name string ,
branch6_code string ,
branch6_name string
)
stored as orcfile;
---------------------------------
有分区的hive表
-------------------------------
use sx_360_safe;
drop table sx_360_safe.life_mbi_epics_info_yb;
create table sx_360_safe.life_mbi_epics_info_yb
(
DEPTNO string,
POLNO string,
PLAN_CODE string,
PAYMENT_DATE string,
TOT_MODAL_PREM string,
REGION_CODE string,
AMT_TYPE string,
PREM_TYPE string,
BUSINESS_TYPE string,
BUSINESS_SRC string,
OP_TYPE string,
POL_YR string,
LCD string,
FCD string,
PK_SERIAL string,
bank_channel_type string
)
PARTITIONED BY ( `day` string)
stored as orcfile;
insert ove
create table sx_360_safe.life_mbi_epics_info_yb1
(
DEPTNO string,
POLNO string,
PLAN_CODE string,
PAYMENT_DATE string,
TOT_MODAL_PREM string,
REGION_CODE string,
AMT_TYPE string,
PREM_TYPE string,
BUSINESS_TYPE string,
BUSINESS_SRC string,
OP_TYPE string,
POL_YR string,
LCD string,
FCD string,
PK_SERIAL string,
bank_channel_type string
)
PARTITIONED BY ( `day` string)
stored as orcfile;
use sx_360_safe;
set mapred.job.queue.name=queue_0101_01;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode = 1000;
set hive.exec.max.dynamic.partitions=1000;
insert overwrite table sx_360_safe.life_mbi_epics_info_yb
partition(day)
select * from sx_360_safe.life_mbi_epics_info_yb1
insert overwrite table sx_360_safe.bas_ela_agent_info
partition(day)
select
id
,code
,parent_code
,type
,type_no
,type_name
,channel
,agent
,openid
,created_date as share_read_time
,referer
,share_source
,share_channel
,detail_no
,wxbind
,substr(created_date,1,10) as statis_date
from sx_360_safe.sx_lvl_trace_info where substr(created_date,1,10) <'2017-01-01' and substr(created_date,1,10) <'2017-09-28' ;
相关文章推荐
- hive建表语句(不同的数据存储格式,包括txt、orc、分区)
- hive修改 表/分区语句
- hive修改 表/分区语句
- hive学习(4)--- hql语句生成job(包括mapper和reducer)的规则探索
- hive学习(5)--- Partitions分区的使用(包括动态分区)
- hive语句 partition(dt=substr('2016-12-01',1,7))取分区问题
- hive修改 表/分区语句
- hive修改 表/分区语句
- hive修改 表/分区语句
- hive修改 表/分区语句
- [hive][转]hive修改 表/分区语句
- hive 修改表/分区语句
- Hadoop 从零开始学习系列-hive从元数据生成表结构、分区等建表语句
- 使用简单的python语句编写爬虫 定时拿取信息并存入txt
- 在Impala 和Hive里进行数据分区(1)
- SQL语句导入导出大全,包括excel,access
- Hive动态分区配置
- Hive既分区又分桶
- Hive-2.HiveQL查询中ORDER BY 和SORT BY 语句|包含SORT BY 的DISTRIBUTE BY|CLUSTER BY
- js 判断浏览器类型(包括全世界最短的语句)