- 進(jìn)入impala shell
impala-shell -i localhost --quiet
- 查看impala版本
[localhost:21000] > select version();
- 查看數(shù)據(jù)庫
[localhost:21000] > show databases;
- 查看當(dāng)前的數(shù)據(jù)庫
[localhost:21000] > select current_database();
- 列出當(dāng)前數(shù)據(jù)庫的表
[localhost:21000] > show tables;
- 列出某個(gè)數(shù)據(jù)庫的表
[localhost:21000] > show tables in dwt
- 模糊查詢某個(gè)數(shù)據(jù)庫的表
[localhost:21000] > show tables in dwt like 'vcc*';
- 進(jìn)入某個(gè)數(shù)據(jù)庫
[localhost:21000] > use dwt;
- 顯示一張表的結(jié)構(gòu)
[localhost:21000] > describe vcc_b_dept;
或者
[localhost:21000] > desc vcc_b_dept;
- 顯示一張表的行數(shù)
[localhost:21000] > select count(*) from vcc_b_dept;
- 顯示某一列不同值的個(gè)數(shù)
[localhost:21000] > select count(distinct dept_no) from vcc_b_dept;
- 顯示dept_no is null的行數(shù)
[localhost:21000]>select count(*) from vcc_b_dept where dept_no is null;
- 顯示某一列10個(gè)不同的值
[localhost:21000] > select distinct dept_no from vcc_b_dept limit 10;
- 創(chuàng)建數(shù)據(jù)庫
[localhost:21000] > create database test_impala;
- 顯示數(shù)據(jù)庫
[localhost:21000] > show databases;
- 模糊查詢數(shù)據(jù)庫
[localhost:21000] > show databases like 'test*';
- 創(chuàng)建一張表
[bigdata1:21000] > create table t1 (x int);
- 將表移動到另一個(gè)數(shù)據(jù)庫中
[bigdata1:21000] > alter table t1 rename to test_impala1.t1;
- 添加數(shù)據(jù)到表里
[bigdata1:21000] > insert into t1 values(1), (2), (3), (4);
- 執(zhí)行函數(shù)
[bigdata1:21000] > select min(x), max(x), sum(x), avg(x) from t1;
- join表
[bigdata1:21000] > select word from t1 join t2 on t1.x = t2.id
- 刪除表
[bigdata1:21000] > drop table if exists tab1;
- 根據(jù)HDFS創(chuàng)建外表
create external table tab1(id int, col_1 boolean,col_2 double,col_3 timestamp) row format delimited fields terminated by ',' location '/user/impala/sample_data/tab1';
- 創(chuàng)建表
create table tab3(id int,col_1 boolean,col_2 double,month int,day int)row format delimited fields terminated by ',';
- 執(zhí)行sql腳本
impala-shell -i localhost -f customer_setup.sql
- 執(zhí)行一條命令
impala-shell -i impala-host -q 'select count(*) from customer_address'
- 匯總查詢
SELECT tab2.col_1, MAX(tab2.col_2), MIN(tab2.col_2) FROM tab2 JOIN tab1 USING (id) GROUP BY col_1 ORDER BY 1 LIMIT 5;
- 子查詢
select tab2.* from tab2, (select tab1.col_1, max(tab2.col_2) as max_col2 from tab2, tab1 where tab2.id = tab1.id group by col_1) subquery1 where subquery1.max_col2 = tab2.col_2;
- insert查詢
insert overwrite table tab3 select id, col_1, col_2, month(col_3), dayofmonth(col_3) from tab1 where year(col_3) = 2012;
- 創(chuàng)建分區(qū)表
create table logs (field1 string, field2 string, field3 string) partitioned by (year string, month string, day string, host string);
- 加載數(shù)據(jù)到分區(qū)表
insert into logs partition(year="2018", month="08", day="28", host="host1") values("foo1", "foo2", "foo3");
- 創(chuàng)建外表
create external table external_logs (field1 string, field2 string, field3 string) partitioned by(year string, month string, day string, host string) location '/user/hive/warehouse/test_impala1.db/logs';
- 添加分區(qū)
alter table external_logs add partition(year="2018", month="08", day="28", host="host1");
Impala簡單教程
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來溶耘,“玉大人二拐,你說我怎么就攤上這事〉时” “怎么了百新?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長庐扫。 經(jīng)常有香客問我饭望,道長,這世上最難降的妖魔是什么形庭? 我笑而不...
- 正文 為了忘掉前任铅辞,我火速辦了婚禮,結(jié)果婚禮上萨醒,老公的妹妹穿的比我還像新娘斟珊。我一直安慰自己,他們只是感情好富纸,可當(dāng)我...
- 文/花漫 我一把揭開白布囤踩。 她就那樣靜靜地躺著,像睡著了一般晓褪。 火紅的嫁衣襯著肌膚如雪堵漱。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼阔拳!你這毒婦竟也來了崭孤?” 一聲冷哼從身側(cè)響起类嗤,我...
- 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎辨宠,沒想到半個(gè)月后遗锣,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡嗤形,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年精偿,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片赋兵。...
- 正文 年R本政府宣布历造,位于F島的核電站甩十,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏吭产。R本人自食惡果不足惜侣监,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望垮刹。 院中可真熱鬧达吞,春花似錦、人聲如沸荒典。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽寺董。三九已至覆糟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間遮咖,已是汗流浹背滩字。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像陶珠,于是被迫代替她去往敵國和親挟裂。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- MYSQL 基礎(chǔ)知識 1 MySQL數(shù)據(jù)庫概要 2 簡單MySQL環(huán)境 3 數(shù)據(jù)的存儲和獲取 4 MySQL基本操...
- 轉(zhuǎn) # https://www.cnblogs.com/easypass/archive/2010/12/ 08/...
- 今天是2018年11月9日狐肢,昨天晚上回來已經(jīng)11點(diǎn)多了,回家后時(shí)間浪費(fèi)了不少沥曹,所以昨天就沒有寫文章份名。 我想要養(yǎng)成一...