hive基礎知識(三)

Hive Hadoop 可視化 技術 六鑰 2017-03-28

4、使用數據庫、查看錶

hive> use a;

OK

Time taken: 0.014 seconds

hive> show tables;

OK

Time taken: 0.058 seconds

5、設置數據庫名的顯示

hive> set hive.cli.print.current.db=true;

$ bin/hive --hiveconf hive.cli.print.current.db=true;

6、建表

hive (a)> create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;

OK

Time taken: 0.131 seconds

7、加載數據

cd /home/hadoop/

ls

cd datas

pwd 打印當前目錄

rz 上傳文件

[hadoop@host-10-10-10-186 datas]$ rz

hive (a)> insert into table student(id,name) values(100,'zhang');

確定文件的位置:

/home/hadoop/datas/student.tsv

hive (a)> load data local inpath '/home/hadoop/datas/student.tsv' into table student;

hive (a)> select * from student;

8、

設置顯示錶頭:

hive (a)> set hive.cli.print.header=true;

hive (a)> select * from student;

不顯示錶頭:

hive (a)> set hive.cli.print.header=false;

9、

查看文件具體信息

$ cat student.tsv

刪除:

rm -rf student.tsv

操作流程:

首先建表:

hive (a)>create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;

$ cd /home/hadoop/

$ ls

$ cd datas

$ ls

$ cat student.tsv

(在本地數據上傳:$ rz :已上傳,不用操作)

$ pwd

顯示的結果:

eg:不是絕對的,看你自己的目錄就可以了

/home/hadoop/datas

hive (a)>load data local inpath '/usr/local/apache-hive-1.2.1-bin/student.tsv' into table student;

hive (a)> select * from student;

hive (a)> set hive.cli.print.header=true;

可視化工具:hue

相關推薦

推薦中...