Search

Is there any alternative way to rename a table without ALTER command?



By using Import and export options we can be rename a table as shown below. Here we are saving the hive data into HDFS and importing back to new table like below.
Shell

EXPORT TABLE tbl_name TO 'HDFS_location';
IMPORT TABLE new_tbl_name FROM 'HDFS_location';



If we prefer to just preserve the data, we can create a new table from old table like
below.

Shell

CREATE TABLE new_tbl_name AS SELECT * FROM old_tbl_name;
DROP TABLE old_tbl_name;