Database Reference
In-Depth Information
When EXTERNAL is used to create a table, Impala treats the table as an external
mean. The data files are produced outside Impala, and when DROP TABLE is called
on that table, the table is removed; however, the underlying data is kept as is.
Because the data file is read directly from HDFS, if there are any changes to the data
file, you must use the REFRESH statement impala-shell so that Impala can recognize
the changes and can use the updated data file. The statement to create a table with
the EXTERNAL clause is the same as CREATE TABLE , and the only difference is that
it starts with CREATE EXTERNAL TABLE as shown in the following line of code:
CREATE EXTERNAL TABLE table_name;
The ALTER TABLE statement
Sometimes, you may need to modify the structure or properties of the table, and
to achieve this objective the ALTER TABLE statement is used. As Impala shares
the table metastore with Hive, the table metadata is updated using ALTER TABLE ,
which is available to any other application using the same metadata. It is important
to know that ALTER TABLE does not actually perform any operation on the actual
data; instead, the alteration is done on metadata. So, to achieve full transformation
of the data, you will need to make those necessary modifications in the data stored
in HDFS.
Here is the statement using ALTER TABLE to rename a table:
ALTER TABLE old_table_name RENAME
new_table_name;
To change the physical location of the directory in HDFS where Impala looks for
table-specific data files, use the following line of code:
ALTER TABLE table_name SET LOCATION
'directory_name_on_HDFS';
You can use the following syntax to change the table data file format to meet Impala
file format requirements:
Search WWH ::




Custom Search