Internal tables are similar to regular database tables in that data may be stored and queried on them. When the data is either temporary or if the lifecycle of the table and data is to be controlled in Hive, or when data and metadata are to be kept inside Hive’s warehouse, an internal or managed table is created.
The default location of the Internal / Managed table is /user/hive/warehouse which is a HDFS directory. This default location can be changed by specifying the desired directory in hive.metastore.warehouse.dir configuration parameter in the hive-site.xml.
If you want to change the default location for a certain table, mention it directly in the CREATE TABLE statement, as illustrated below.
CREATE TABLE Books (
BookID INT,
BookName STRING
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘,’
LOCATION ‘/user/cloudera/BooksDir’;
Please keep in mind that the directory does not have to exist prior to the creation of the table. Hive will take care of that.
Hope you find this article helpful.
Please do subscribe for more interesting updates.
One comment