Hive基础知识-3

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容