Hive 3 Hive 基本使用

2021-09-10 13:49:31 字數 1006 閱讀 8931

1、 建立庫:create database if not exists mydb;

2、 檢視庫:show databases;

3、 切換資料庫:use mydb;

4、 建立表:create table if not exists t_user(id string, name string) 或 create table t_user(id string, name string) row format delimited fields terminated by ',';

5、 檢視表列表:show tables;

6、 插入資料:insert into table t_user values ('1','huangbo'), ('2','xuzheng'), ('3','wangbaoqiang');

7、 查詢資料:select * from t_user;

8、 匯入資料: 

a) 匯入 hdfs 資料:load data inpath '/user.txt' into table t_user; 

b) 匯入本地資料:load data local inpath '/home/hadoop/user.txt' into table t_user; 

user.txt 的資料為: 

4,liudehua 

5,wuyanzu

6,liangchaowei

9、再次查詢資料:select * from t_user; 

小技能補充:

1、 進入到使用者的主目錄,使用命令 cat /home/hadoop/.hivehistory 可以檢視到 hive 執行的 歷史命令 

2、 執行查詢時若想顯示表頭資訊時,請執行命令: hive> set hive.cli.print.header=true; 

3、 hive的執行日誌的儲存目錄在$/$/hive.log中,假如使用hadoop 使用者操作的 hive,那麼日誌檔案的儲存路徑為:/temp/hadoop/hive.log  

Hive基本使用

啟動hadoop sbin start all.sh 啟動hive bin hive 建立表 create table table name col name data type comment col comment create table hive wordcount context stri...

HIVE基本使用

筆者注 這裡安裝的版本為hive 0.13.1 注 表示可選 create database if not exists db hive use db hive drop database if exists db hive create table stu id int name string r...

Hive基本使用

hive基本使用 庫操作 建立庫 進入終端 beeline u jdbc hive2 n user 判斷是否存在並新增注釋 create database if not exists zxl test comment hive test 新增屬性 create database if not exi...