hive 0.9999999

創建表:
Hive> CREATE TABLE pokes (foo INT, bar STRING);
Creates a table called pokes with two columns, the first being an integer and the other a string
創建一個新表,結構與其他一樣
hive> create table new_table like records;
創建分區表:
hive> create table logs(ts bigint,line string) partitioned by (dt String,country String);
加載分區表數據:
hive> load data local inpath /home/Hadoop/input/hive/partitions/file1 into table logs partition (dt=2001-01-01,country=GB);
展示表中有多少分區:
hive> show partitions logs;
展示所有表:
hive> SHOW TABLES;
lists all the tables
hive> SHOW TABLES .*s;
lists all the table that end with s. The pattern matching follows Java regular
expressions. Check out this link for documentationhttp://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html
顯示表的結構信息
hive> DESCRIBE invites;
shows the list of columns
更新表的名稱:
hive> ALTER TABLE source RENAME TO target;
添加新一列
hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT a comment);

刪除表:
hive> DROP TABLE records;
刪除表中數據,但要保持表的結構定義
hive> dfs -rmr /user/hive/warehouse/records;
從本地文件加載數據:
hive> LOAD DATA LOCAL INPATH /home/hadoop/input/ncdc/micro-tab/sample.txt OVERWRITE INTO TABLE records;
顯示所有函數:
hive> show functions;
查看函數用法:
hive> describe function substr;
查看數組、map、結構
hive> select col1[0],col2[b],col3.c from complex;

內連接:
hive> SELECT sales.*, things.* FROM sales JOIN things ON (sales.id = things.id);
查看hive為某個查詢使用多少個MapReduce作業
hive> Explain SELECT sales.*, things.* FROM sales JOIN things ON (sales.id = things.id);
外連接:
hive> SELECT sales.*, things.* FROM sales LEFT OUTER JOIN things ON (sales.id = things.id);
hive> SELECT sales.*, things.* FROM sales RIGHT OUTER JOIN things ON (sales.id = things.id);
hive> SELECT sales.*, things.* FROM sales FULL OUTER JOIN things ON (sales.id = things.id);
in查詢:Hive不支持,但可以使用LEFT SEMI JOIN
hive> SELECT * FROM things LEFT SEMI JOIN sales ON (sales.id = things.id);

Map連接:Hive可以把較小的表放入每個Mapper的內存來執行連接操作
hive> SELECT /*+ MAPJOIN(things) */ sales.*, things.* FROM sales JOIN things ON (sales.id = things.id);
INSERT OVERWRITE TABLE ..SELECT:新表預先存在
hive> FROM records2
> INSERT OVERWRITE TABLE stations_by_year SELECT year, COUNT(DISTINCT station) GROUP BY year
> INSERT OVERWRITE TABLE records_by_year SELECT year, COUNT(1) GROUP BY year
> INSERT OVERWRITE TABLE good_records_by_year SELECT year, COUNT(1) WHERE temperature != 9999 AND (quality = 0 OR quality = 1 OR quality = 4 OR quality = 5 OR quality = 9) GROUP BY year;
CREATE TABLE ... AS SELECT:新表表預先不存在
hive>CREATE TABLE target AS SELECT col1,col2 FROM source;
創建視圖:
hive> CREATE VIEW valid_records AS SELECT * FROM records2 WHERE temperature !=9999;
查看視圖詳細信息:
hive> DESCRIBE EXTENDED valid_records;insert overwrite table t_table1 select * from t_table1 where XXXX; 其中xxx是你需要保留的數據的查詢條件。 如果清空表,如下: insert overwrite table t_table1 select * from t_table1 where 1=0;
實踐的意思 60后熟女生活照 鋁箔紙印刷機 寒刃2無限掃蕩 the only child 彩圖 專業減肥店的貓膩 宜人貸股價 華為穿戴appios 電腦桌面壁紙設置 廣州站西批發 申愽亞洲官方網站 上海交大理科實驗班 httpwebresponse 400 北京21號線地鐵線路圖 普洱熟茶排名 jar包打成war打包 去掉li樣式 ubuntu 14.04進入圖形 unity ios熱更新 共同基金常識高清 pdf 三洋 松下 微波爐 654845 東京夜店能帶走女的嗎 民營經濟占gdp比重 最強NBA哪個中鋒好 醫療保障制度 劍姬無慘 剣姫 劍雨阿難是誰 akiswhere珍珠 渠首黃酒價格

Copyright 知識通 Some Rights Reserved

如反饋或投訴等情況聯系:une35498#163.com

广西十一选五走势