"Go" hive internal table, external table

Source: Internet
Author: User

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?
    1. 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?
    1. 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?
    1. 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?
    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.