hive的基本操作(一)

2021-10-24 14:38:16 字數 1383 閱讀 8459

hive的常用操作

1.檢視資料庫

show databases;

2.使用(進入)資料庫;

use db_hive;(db_hive是資料庫名)

3.檢視資料庫內的資料表

show tables;

4.檢視表結構

5.檢視表資料

6.向表中新增資料

insert into student values(2,'daqiao',12),(3,'xiaoqiao',13);

7.建立分割槽表

create external table stu1(name string,age int) partitioned by (dt string) row format delimited fields terminated by ' ';

匯入資料

8.建立二級分割槽表

create external table stu(name string,age int) partitioned by (year string,month string)

row format delimited fields terminated by ' ';

檢視二級分割槽表結構

二級分割槽表新增資料

load data local inpath '/root/1.txt' into table stu partition (year='2020',month='10');

load data local inpath '/root/1.txt' into table stu partition (year='2020',month='11');

檢視資料

hive的基本操作

建立表 create table table name col name data type comment col comment create table hive wordcount context string 載入資料到hive表 load data local inpath filepa...

Hive的基本操作

建立庫 create database if not exists xxuu test 查詢庫 show databases show databases like xxuu 庫資訊 查詢庫的hdfs路徑 desc database xxuu test desc database extended ...

hive基本操作

1.顯示所有資料庫 show databases 2.使用某個資料庫 use xx xx表示某個資料庫名 3.顯示某資料庫下的所有表 show tables 4.檢視表結構 顯示各欄位 desc 表名 5.資料匯出到本地 在hive中操作 insert overwrite local directo...