<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] # 分區表 ## 增加 ### 創建表 ~~~ hive> create table t_patition(ip string,duration int) > partitioned by(country string) > row format delimited > fields terminated by ','; OK Time taken: 0.086 seconds ~~~ ### 創建多級分區表 ~~~ hive> create table t_patition(ip string,duration int) > partitioned by(country string,city string) > row format delimited > fields terminated by ','; ~~~ 數據又分成了一半,在country文件夾下在分city文件 ### 插入單個分區 我們來用文件來填充數據 注意我們要指定分區的,因為他的分區表 ~~~ //把整個文件載入到這個分區 hive> load data local inpath '/root/ip.txt' into table t_patition partition(country="china"); ~~~ ### 插入多級分區 ~~~ load data local inpath '/root/ip.txt' into table t_patition partition(country="china", city="hanzou"); ~~~ ## 查詢 ### 查看表的詳情 ~~~ hive> desc t_patition; ~~~ ### 查詢數據 查詢的時候,后面會顯示分區 ~~~ hive> select * from t_patition; OK 192.168.1.100 1 china 192.168.1.200 2 china ~~~ 也可以只查指定分區的數據 ~~~ hive> select * from t_patition where country="china"; ~~~ ### 查詢多級分區 ~~~ select * from t_patition where country="china" and city="hanzou"; ~~~ ### 多分區聯合查詢 ~~~ select * from t_patition where country="china" union select * from t_patition where country="japan"; union select * from t_patition where country="us"; ~~~ ### 查詢表的分區 ~~~ show partitions dept_partition; ~~~ ## 刪除 ### 刪除一個分區 ~~~ alter table dept_patition drop partition(month="201705"); ~~~ ### 同時刪除多個分區 `alter table dept_patition drop partition(month="201705"),partition(month="201706");` ## 改 ### 創建單個分區 ~~~ alter table dept_patition add partition(month="201705"); ~~~ ### 同時創建多個分區 ~~~ alter table dept_patition add partition(month="201705") partition(month="201706"); ~~~ # 分區數據關聯 把數據直接上傳到分區目錄下,讓分區表和數據產生關聯 ## 上傳數據后修復 我們先在hive中創建個文件夾 ~~~ dfs -mkdir -p /user/hive/warehouse/db1.db/t_patition/country=japan; ~~~ 把數據上傳到這個文件夾 ~~~ dfs -put /root/study/ip.txt /user/hive/warehouse/db1.db/t_patition/country=japan; ~~~ 然后我們查詢下 ~~~ select * from t_patition where country="japan"; ~~~ 發現查詢不到,因為關聯不上 修復下,他就會把分區添加到元數據 ~~~ msck repair table t_patition; ~~~ 然后就能查詢到了 ## 上傳數據后添加分區 我們先創建目錄,然后上傳文件 ~~~ hive (db1)> dfs -mkdir -p /user/hive/warehouse/db1.db/t_patition/country=x; hive (db1)> dfs -put /root/study/ip.txt /user/hive/warehouse/db1.db/t_patition/country=x; ~~~ 然后這時對表進行alter添加分區,這個情況下就不用修復了 ~~~ alter table t_patition add partition(country='x'); ~~~ ## 上傳數據后load數據到分區 創建文件夾 ~~~ dfs -mkdir -p /user/hive/warehouse/db1.db/t_patition/country=y; ~~~ 把數據load到分區中 ~~~ load data local inpath '/root/study/ip.txt' into table t_patition partition(country='y'); ~~~ 然后這時就可以查詢到了
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看