vi xxx.txt --本地創建TXT文件數據
hive; --打開hive
use test; --使用test庫
create table econnoisseur_sec ( user_id string, type string, detail string ) row format delimited fields terminated by '\t' stored as textfile
若未指定為外部表(external table),則默認為托管表(managed table)。二者的區別在於load與drop操作:托管表用load data inpath加載數據(路徑可為本地目錄,也可是HDFS目錄),該操作會將該文件放在HDFS目錄:/user/hive/warehouse/ 下;而外部表的數據是在location中指定,一般配合partition描述數據的生成信息;drop托管表時會將元數據與/user/hive/warehouse/下的數據一起刪掉,而drop外部表時只會刪除元數據。
load data local inpath '/home/spark/gama/xxx.txt' overwrite into table test.econnoisseur_sec; --填寫xxx.txt 路徑並且導入數據
