hive內部表和外部表的區別
阿新 • • 發佈:2019-02-12
內部表:
1:內部表也稱為MANAGED_TABLE
2:內部表預設儲存在/user/hive/warehouse下面
3:(1)從hdfs往內部表載入資料:load data inpath '/student.txt' into table student
會將hdfs上面的資料剪下到/user/hive/warehouse/student下面,同時刪除hdfs上面的student.txt檔案
(2)從本地(虛擬機器)往內部表載入資料:load datalocal inpath '/student.txt' into table student
4:刪除外部表時,會刪除表資料以及元資料
外部表:
1:外部表也稱為EXTERNAL_TABLE
2:建立外部表語句: createexternal student( ).......
3:建立外部表時可以指定需要載入的資料位置:location '/student.txt'
就相當於我們通過信封上的地址找到你的家所在的位置。
4:因為外部表載入資料時只是指向了資料的位置,所以刪除外部表時只會刪除表的元資料不會刪除表資料。