日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql内表和外表_Hive内表和外表的区别

發布時間:2023/12/2 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql内表和外表_Hive内表和外表的区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文以例子的形式介紹一下Hive內表和外表的區別。例子共有4個:不帶分區的內表、帶分區的內表、不帶分區的外表、帶分區的外表。

1 不帶分區的內表

#創建表

create table innerTable(id int,name string) row format delimited fields terminated by ‘|’;(show tables發現沒有innerTable,只有innertable。不多說,記住了)

#從HDFS上加載數據

load data inpath ‘hdfs://master:9000/user/root/test/innerTable’ into table innertable; (查看HDFS上/user/root/test/innerTable,發現文件價innerTable還在,但是里面的文件已經不在了。去哪了,去innertable表中了)

#刪除剛剛創建的表

drop table innertable;(到HDFS上看一下innertable文件夾及其中的文件都沒有了。去哪了,刪除表的時候刪除了)

2 帶分區的內表

#創建表

create table inner_table_with_p(id int,name string) partitioned by (part_num int);(HDFS 出現文件夾inner_table_with_p,文件夾中為空)

#從HDFS加載數據

load data inpath ‘hdfs://master:9000/user/root/test/innerTable/part1′ into table inner_table_with_p partition(part_num=1)(文件夾inner_table_with_p出現子文件夾part_num=1,innerTable中part1消失);

load data inpath ‘hdfs://master:9000/user/root/test/innerTable/part2′ into table inner_table_with_p partition(part_num=2)(文件夾inner_table_with_p出現子文件夾part_num=2,innerTable中part2消失);

load data inpath ‘hdfs://master:9000/user/root/test/innerTable/part3′ into table inner_table_with_p partition(part_num=3)(文件夾inner_table_with_p出現子文件夾part_num=3,innerTable中part3消失);

#刪除分區

alter table inner_table_with_p drop partition(part_num=1);(part_num=1對應分區文件夾本刪除)

#刪除表

drop table inner_table_with_p;(HDFS上inner_table_with_p文件夾被刪除)

3 不帶分區的外表

創建表

create external table outer_table(id int,name string) row format delimited fields terminated by ‘|’;? ? ? (hive倉儲目錄中出現outer_table)

加載數據

load data inpath ‘/user/root/test/outerTable/outer’ into table outer_table;(outer_table中出現子文件outer,outerTable中outer消失)

刪除表

drop table outer_table;? ? (outer_table及子文件outer依然存在,因為這是外表)

4 帶分區的外表

創建表

create external table outer_table_with_p(id int,name string) partitioned by (part_num int) row format delimited fields terminated by ‘|’; (hive倉儲目錄中出現outer_table_with_p)

加載數據

load data inpath ‘/user/root/test/outerTable/part1′ into table outer_table_with_p partiton(part_num=1);? (outer_table_with_p中出現子文件夾part_num=1)

load data inpath ‘/user/root/test/outerTable/part2′ into table outer_table_with_p partition(part_num=2);(outer_table_with_p中出現子文件夾part_num=2)

load data inpath ‘/user/root/test/outerTable/part3′ into table outer_table_with_p partition(part_num=3);(outer_table_with_p中出現子文件夾part_num=3)

刪除分區

alter table outer_table_with_p drop partition(part_num=1);(HDFS上分區文件依舊存在)

刪除表

drop table outer_table_with_p;(HDFS上對應數據依舊存在)

總結:

1 刪除內表時,內表數據會一并刪除;

2 刪除外表時,外表數據依舊存在。

推薦閱讀:

總結

以上是生活随笔為你收集整理的mysql内表和外表_Hive内表和外表的区别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。