Hive internal table, external table is different from needless to say, can be used when the actual use of caution.
1. Internal table:
[SQL]View Plaincopyprint?
- Create Table TT (name string, age string) location '/input/table_data ';
At this point, a new data storage location for the TT table is created on HDFs, for example, the author is in Hdfs://master/input/table_data
Upload the HDFS data to the table:
[SQL]View Plaincopyprint?
- Load data inpath '/input/data ' into table TT;
The data under the/input/data directory on HDFs is transferred to the/input/table_data directory.
After deleting the TT table, the data and metadata information of the TT table will be deleted, that is, there is no data at the end of the/input/table_data, of course, there is no data/input/data under the previous step!
If no location is specified when creating the internal table, a new table directory is created under/user/hive/warehouse/and the remainder is the same.
The point to note is that load data will be transferred!
2. External table:
[SQL]View Plaincopyprint?
- Create external table ET (name string, age string);
At this point, a new table directory is created in/user/hive/warehouse/et
[SQL]View Plaincopyprint?
- Load data inpath '/input/edata ' into table et;
The data under the/input/edata/on HDFs will be transferred to/user/hive/warehouse/et, and after the external table is deleted, the data under/user/hive/warehouse/et will not be deleted, but/input/edata/ The data below has been lost in the previous step of the load! The location of the data has changed! The essence is that data on an HDFS will be transferred when it is load!
3. Other:
(1) Add location usage, but the table directory is different.
(2) plus partition usage is the same, only the table directory will have a partition directory.
(3) The load data local Inpath directly uploads the local file system to HDFs, where it is uploaded to the location specified, without uploading to the hive's default configuration Data Warehouse.
"Go" hive internal table, external table