Hive建立外部表表external table

Hive建表(外部表external table):

CREATE EXTERNAL TABLE `table_name`(
  `column1` string, 
  `column2` string, 
  `column3` string)
PARTITIONED BY ( 
  `proc_date` string)
ROW FORMAT SERDE 
  'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
  'hdfs://ns-hf/...'
TBLPROPERTIES ()TBLPROPERTIES (
  'transient_lastDdlTime'='')

添加分区并加载分区数据:

alter table table_name add partition (proc_date='${hivevar:pdate}'location '...'(不改变源数据存储位置)

load data inpath '...' into table table_name partition(proc_date='${hivevar:pdate}');(会将源数据切到hive表指定的路径下)

删除分区:alter table table_name drop if exists partition(proc_date='${hivevar:pdate}');


你可能感兴趣的:(大数据)