hadoop hive基本操作

2021-07-31 05:37:09 字數 1197 閱讀 7706

hive 基本操作

命令:hive shell  || hive --service cli

進入shell後

1. 設定顯示當前database和顯示列欄位

set hive.cli.print.current.db=true   //顯示當前db

set hive.cli.print.headers=true      //顯示列

2. 相關命令

show databases

show tables

use database_name

create database database_name

//建表

create external table table_name(

id int,

name string)

row format delimited

fields terminated by '\t'

lines terminated by '\n'

stored as textfile;

//匯出資料到本地

insert overwrite local directory '/root/data.dat'

select * from table_name;

//匯出資料到另乙個表

insert overwrite table to_table

select * from from_table

//匯出資料到hdfs檔案(比匯出到本地少個local)

insert overwrite directory '/root/hdfs'

select * from from_table

//從本地檔案匯入資料到hive

load data [local] inpath '/data/userdata' [overwrite] into table user;

//overwrite關鍵會全表覆蓋,如果只是想附加資料,將overwrite去掉即可

//從hdfs匯入資料到hive

load data inpath `/tmp/date.txt` overwrite into table page_view partition(pt='2008-06-08')

//從某個表匯入

nsert overwrite table tmp_t1 select * from tmp_t2;

Hadoop Hive 庫表基本操作

hive 庫表基本操作 建立資料庫 hive create database if not exists db1 hive create schema if not exists db2 刪除資料庫 hive drop database db2 hive drop schema db1 建立表 cr...

學習Hadoop Hive 介紹

1.由facebook 開源,最初用於解決海量結構化的日誌資料統計問題 etl extraction transformation loading 工具 2.構建在hadoop 之上的資料倉儲 資料計算使用mr,資料儲存使用hdfs 3.hive 定義了一種型別sql查詢語句 hql,類似於sql,...

Hadoop Hive 字段型別

分類 型別描述 字面量示例 原始型別 boolean true false true tinyint 1位元組的有符號整數 128 1271y smallint 2個位元組的有符號整數,32768 327671s int4個位元組的帶符號整數1 bigint 8位元組帶符號整數1l float 4位...