Internal and External tables

Internal Tables:

  • Managed by Hive, meaning Hive controls the lifecycle of the data.

  • Data is stored in the Hive warehouse directory.

  • Dropping an internal table deletes both the table schema and the data.

CREATE TABLE internal_table (
    id INT,
    name STRING,
    age INT
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE;

External Tables:

  • Managed by the user, meaning the user controls the lifecycle of the data.

  • Data is stored at an external location specified by the user.

  • Dropping an external table only deletes the table schema, not the data.

CREATE EXTERNAL TABLE external_table (
    id INT,
    name STRING,
    age INT
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION '/path/to/external/data';

Last updated

Was this helpful?