Create External Table in Hive: Step-by-Step

The method for creating an external table in Hive is as follows:

  1. Create an external table in Hive using the CREATE EXTERNAL TABLE statement, the syntax is as follows:
CREATE EXTERNAL TABLE table_name (
    column1 data_type,
    column2 data_type,
    ...
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LOCATION 'hdfs_path';
  1. In the CREATE EXTERNAL TABLE statement, it is important to specify the column names, data types, delimiter, and storage location of the external table.
  2. The difference between external and internal tables is that the data of external tables is stored in a specified location in HDFS, while the data of internal tables is stored in the default storage path of Hive.
  3. External tables allow users to query data in Hive and also access the data in external tables directly through HDFS or other tools.
  4. The metadata information of the external table in Hive will be recorded in Hive’s metadata, but the data files themselves will not be moved or copied to the default storage path of Hive.

The aforementioned method can be used to create an external table in Hive, allowing for querying and management of external data.

bannerAds