1.建立一張內部表
create
table inner_table(id int
, name string)
row format delimited fields
terminated
by','
;注意:delimited fields
terminated
by','
--- 以逗號結尾的分隔字段
2.將本地txt檔案匯入
load
data
local inpath "/home/temp/student.txt"
into inner_table;
3.檢視hdfs的檔案目錄
4. 刪掉表
drop
table inner_table;
5.再次檢視hdfs目錄,檔案已經不在了
1.建立一張內部表
create
table inner_table(id int
, name string)
row format delimited fields
terminated
by','
;
2.在hdfs上任意乙個目錄上傳檔案
2.將hdfs的/tmp目錄的檔案匯入到inner_table表
load
data inpath "/tmp/student.txt"
into
table inner_table;
//和本地相比少了個local引數
3.檢視hdfs的/tmp/目錄下的student.txt檔案–已經被轉移,不存在了
4. 檢視inner_table表對應的hdfs目錄–已經匯入
5. 刪掉表
drop
table inner_table;
6.再次檢視inner_table對應的hdfs目錄,檔案已經不在了
1.建立一張外部表
create external table external_table(id int
, name string)
row format delimited fields
terminated
by','
;
2.將本地txt檔案匯入
load
data
local inpath "/home/temp/student.txt"
into
table external_table;
3.檢視hdfs的檔案目錄
4. 刪掉表
drop
table external_table;
5.再次檢視hdfs目錄 – 檔案還在
1.建立一張內部表
create external table my_external_table(id int
, name string)
row format delimited fields
terminated
by','
;
2.在hdfs上任意乙個目錄上傳檔案
2.將hdfs的/tmp目錄的檔案匯入到my_external_table表
load
data inpath "/tmp/student.txt"
into
table my_external_table;
//和本地相比少了個local引數
3.檢視hdfs的/tmp/目錄下的student.txt檔案–已經被轉移,不存在了![](https://pic.w3help.cc/cb3/d0c4fb77e3ec70c484550f57985a3.jpeg)
4. 檢視my_external_table表對應的hdfs目錄–已經匯入
5. 刪掉表
drop
table my_external_table;
6.再次檢視my_external_table對應的hdfs目錄–檔案還在
1.不管是內部表還是外部表,從hdfs上匯入資料到對應的表的時候,原目錄下的資料都會被轉移到新的目錄
2.內部表在刪除表的時候,hdfs上的資料一併刪除;
3.外部表在刪除表的時候,hdfs上的資料不會刪掉;
hive外表和事務表
建立外表 beeline u jdbc hive2 n hdfs t location tmp nj12345 case info 建立事務表 clustered by case serial into 250 buckets stored as orc insert insto orc事務表 se...
Hive 之內 外表 與 分割槽表 桶表區別
內錶 刪表刪資料 hdfs上的檔案資料 外表 刪表不刪資料 hdfs上的檔案資料 外表 包含external 的表叫外部表 分割槽表 加入分割槽避免hive select查詢中掃瞄整個表內容,會消耗很多時間做沒必要的工作。例如每一天的日誌存放在乙個分割槽中,這樣根據特定的日期查詢 乙個表可以擁有乙個...
Hive 內錶和外表的區別
原文 1.內部表 create table zz name string age string location input table data 注 hive預設建立的是內部表 此時,會在hdfs上新建乙個zz表的資料存放地 load data inpath input data into tab...