hiveserver和beeline(hiveserver2)的區別:
hive:
連線方式
hive -h hostname -p port
載入檔案
庫級操作
表級操作
行級操作
關於各種建表語句
檔案employee.txt
michael|montreal,toronto|male,30|db:80|product:developerlead
will|montreal|male,35|perl:85|product:lead,test:lead
shelley|new york|female,27|python:80|test:lead,coe:architect
lucy|vancouver|female,57|sales:89,hr:94|sales:lead
檔案employee_id.txt
michael|100|montreal,toronto|male,30|db:80|product:developerlead
will|101|montreal|male,35|perl:85|product:lead,test:lead
steven|102|new york|female,27|python:80|test:lead,coe:architect
lucy|103|vancouver|female,57|sales:89,hr:94|sales:lead
mike|104|montreal|male,35|perl:85|product:lead,test:lead
shelley|105|new york|female,27|python:80|test:lead,coe:architect
luly|106|vancouver|female,57|sales:89,hr:94|sales:lead
lily|107|montreal|male,35|perl:85|product:lead,test:lead
shell|108|new york|female,27|python:80|test:lead,coe:architect
mich|109|vancouver|female,57|sales:89,hr:94|sales:lead
dayong|110|montreal|male,35|perl:85|product:lead,test:lead
sara|111|new york|female,27|python:80|test:lead,coe:architect
roman|112|vancouver|female,57|sales:89,hr:94|sales:lead
christine|113|montreal|male,35|perl:85|product:lead,test:lead
eman|114|new york|female,27|python:80|test:lead,coe:architect
alex|115|vancouver|female,57|sales:89,hr:94|sales:lead
alan|116|montreal|male,35|perl:85|product:lead,test:lead
andy|117|new york|female,27|python:80|test:lead,coe:architect
ryan|118|vancouver|female,57|sales:89,hr:94|sales:lead
rome|119|montreal|male,35|perl:85|product:lead,test:lead
lym|120|new york|female,27|python:80|test:lead,coe:architect
linm|121|vancouver|female,57|sales:89,hr:94|sales:lead
dach|122|montreal|male,35|perl:85|product:lead,test:lead
ilon|123|new york|female,27|python:80|test:lead,coe:architect
elaine|124|vancouver|female,57|sales:89,hr:94|sales:lead
建立庫hivetest:
create database hivetest;
切換到庫hivetest:
use hivetest;
建立表employee:(字段型別)
create table employee( #建立名為employee的表
name string, #欄位名
address array, #欄位型別為array
personalinfo array,
technol map, #欄位型別為map
jobs map)
row format delimited #對**的分割符進行格式化
fields terminated by '|' #設定列的分割符
collection items terminated by ',' #設定array的分割符
map keys terminated by ':' #設定map的分割符
lines terminated by '\n'; #設定行的分割符
建立表employee_id:
create table employee_id(
name string,
id int,
address array,
info struct, #欄位型別為struct
technol map,
jobs map)
row format delimited
fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n';
建立分割槽表employee_partition:
create table employee_partition(
name string,
address array,
info struct,
technol map,
jobs map)
partitioned by (country string,add string) #分割槽型別自定義
row format delimited
fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n';
建立外部表emp_id:
create external table emp_id(
name string,
id int,
address array,
info struct,
technol map,
jobs map)
row format delimited
fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n'
stored as textfile #指定要儲存在hdfs上的位置路徑要提前建立好
location '/usr/test/employee';
建立分通表emp_bucket:
create external table emp_bucket(
name string,
id int,
address array,
info struct,
technol map,
jobs map)
clustered by(id) into 3 buckets
row format delimited
fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n'
stored as textfile
location '/usr/test/bucket';
set hive.enfore.bucketing=true; #是否進行分桶
hive查詢語法
1.建立表 create table value data citing int,cited int row format delimited fields terminated by stored as textfile 2.檢視新建的表 show tables 3.檢視新建表的結構 descri...
Hive知識之Hive基礎
5 hive的基本操作 5.2 資料表相關操作 6 資料的匯入和匯出 1 hive簡介 2 hive與傳統關係型資料庫的比較 專案hive rdbms 查詢語言 hqlsql 資料儲存 hdfs raw device or local fs 執行mapreduce excuter 執行延遲高低 處理...
hive相關語法與操作
參考 hive操作參考 模板 create database if not exists dw fltdb use dw fltdb drop table if exists dw fltdb.factfltsegordersnap2015 08 create table if not exists...