hive建表语句
Posted heguoxiu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive建表语句相关的知识,希望对你有一定的参考价值。
----导入hdfs建表
use ods_db;
CREATE EXTERNAL TABLE BER_O2O_PV
(
JSON STRING
)PARTITIONEDBY(YEARSTRING,MONTHSTRING)
STORED AS TEXTFILE
LOCATION ‘/ODS/ODS_DB/BER_O2O_PV‘;
CREATE EXTERNAL TABLE BER_O2O_USER_LABLE
(
LABLE_ID STRING,
LABLE_NAME STRING,
LABLE_TYPE STRING,
RID STRING,
LEVEL_ID STRING
)ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘
STORED AS TEXTFILE
LOCATION ‘/ODS/ODS_DB/BER_O2O_USER_LABLE‘;
----------hive分析建表
USE PARSEDB;
---TMP----
CREATE TABLE FACT_BI_BROWSER_T_00
(
CHANNEL STRING,
SESSION_ID STRING,
APP_ID STRING,
IP STRING,
REF_URL STRING,
URL STRING,
STAY_TIME STRING,
LOG_TIME STRING,
BROWSER STRING
) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ 01‘
STORED AS TEXTFILE;
CREATE TABLE FACT_BI_BROWSER_T_01
(
BR_NAME STRING,
BI_VALUE DOUBLE,
BI_DATETIME STRING,
BI_CHANNEL STRING
)ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ 01‘
STORED AS TEXTFILE;
----FACT-----
CREATE EXTERNAL TABLE FACT_BI_BROWSER_T
(
ID STRING,
BI_TYPE STRING,
BR_NAME STRING,
BI_VALUE DOUBLE,
BI_DATETIME STRING,
BI_CHANNEL STRING
)PARTITIONED BY (YEAR STRING, MONTH STRING, DAY STRING )
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ 01‘
STORED AS TEXTFILE
LOCATION ‘/RESULT/PARSEDB/FACT_BI_BROWSER_T‘;
以上是关于hive建表语句的主要内容,如果未能解决你的问题,请参考以下文章