外部表和内部表

An external table behaves differently. You control the creation and deletion of the data. The location of the external data is specified at table creation time: EXTERNAL 关键字可以让用户创建一个外部表,在建表的同时指定一个指向实际数据的路径(LOCATION),Hive 创建内部表时,会将数据移动到数据仓库指向的路径;若创建外部表,仅记录数据所在的路径,不对数据的位置做任何改变。在删除表的时候,内部表的元数据和数据会被一起删除,而外部表只删除元数据,不删除数据

创建外部表: create external table ext_record(col1 string,col2 string)row format delimited fields terminated by '\t' location '/user/root/input'; 这样表ext_record的数据就是hdfs://user/root/input/*.txt的数据了

猜你喜欢

转载自java-doom.iteye.com/blog/1878683