Alter table feature

In Hive or Impala, you can use ALTER TABLE to set table properties. From Impala, you can use ALTER TABLE to rename a table, to change the table owner, or to change the role of the table owner. From Hive, you can alter the metadata location of the table if the new metadata does not belong to another table; otherwise, an exception occurs.

Hive or Impala syntax

ALTER TABLE table_name SET TBLPROPERTIES table_properties;
  • table_properties
    A list of properties and values using the following syntax:
    (property_name = property_value, property_name = property_value, ... )

Impala syntax

ALTER TABLE table_name RENAME TO new_table_name;

ALTER TABLE table_name set OWNER USER user_name;

ALTER TABLE table_name set OWNER ROLE role_name;

Hive example

ALTER TABLE test_table SET TBLPROPERTIES('metadata_location'='s3a://bucketName/ice_table/metadata/v1.metadata.json');

Impala examples

ALTER TABLE t1 RENAME TO t2;

ALTER TABLE t CHANGE COLUMN d d DECIMAL (22, 3) AFTER i;

ALTER TABLE ice_table set OWNER USER john_doe;

ALTER TABLE ice_table set OWNER ROLE some_role;

ALTER TABLE prod.db.sample SET TBLPROPERTIES ('read.split.target-size'='268435456');