Impala的操作命令之 内外shell

2.4 Impala的初体验

1.启动Impala

[root@hadoop102 ~]# impala-shell

2.查看数据库

[hadoop102:21000] > show databases;

3.打开默认数据库

[hadoop102:21000] > use default;

4.显示数据库中的表

[hadoop102:21000] > show tables;

5.创建一张student表

[hadoop102:21000] > create table student(id int, name string)
                  > row format delimited
                  > fields terminated by '\t';

6.向表中导入数据

[hadoop103:21000] > load data inpath '/student.txt' into table student;

注意:

1)关闭(修改hdfs的配置dfs.permissions为false)或修改hdfs的权限,否则impala没有写的权限

[hdfs@hadoop103 ~]$ hadoop fs -chmod -R 777 /

2)Impala不支持将本地文件导入到表中
7.查询

[hadoop103:21000] > select * from student;

8.退出impala

[hadoop103:21000] > quit;

Impala的操作命令

3.1 Impala的外部shell

选项 描述

在这里插入图片描述

1.连接指定hadoop103的impala主机

[root@hadoop102 datas]# impala-shell -i hadoop103

2.使用-q查询表中数据,并将数据写入文件中

[hdfs@hadoop103 ~]$ impala-shell -q 'select * from student' -o output.txt

3.查询执行失败时继续执行

[hdfs@hadoop103 ~]$ vim impala.sql
select * from student;
select * from stu;
select * from student;
[hdfs@hadoop103 ~]$ impala-shell -f impala.sql;
[hdfs@hadoop103 ~]$ impala-shell -c -f impala.sql;

4.在hive中创建表后,使用-r刷新元数据

hive> create table stu(id int, name string);
[hadoop103:21000] > show tables;
Query: show tables
+---------+
| name    |
+---------+
| student |
+---------+
[hdfs@hadoop103 ~]$ impala-shell -r
[hadoop103:21000] > show tables;
Query: show tables
+---------+
| name    |
+---------+
| stu     |
| student |
+---------+

5.显示查询执行计划

[hdfs@hadoop103 ~]$ impala-shell -p
[hadoop103:21000] > select * from student;

6.去格式化输出

[root@hadoop103 ~]# impala-shell -q 'select * from student' -B --output_delimiter="\t" -o output.txt
[root@hadoop103 ~]# cat output.txt 
1001    tignitgn
1002    yuanyuan
1003    haohao
1004    yunyun

3.2 Impala的内部shell

选项 描述

在这里插入图片描述

1.查看执行计划

explain select * from student;

2.查询最近一次查询的底层信息

[hadoop103:21000] > select count(*) from student;
[hadoop103:21000] > profile;

3.查看hdfs及linux文件系统

[hadoop103:21000] > shell hadoop fs -ls /;
[hadoop103:21000] > shell ls -al ./;

4.刷新指定表的元数据

hive> load data local inpath '/opt/module/datas/student.txt' into table student;
[hadoop103:21000] > select * from student;
[hadoop103:21000] > refresh student;
[hadoop103:21000] > select * from student;

5.查看历史命令

[hadoop103:21000] > history;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值