C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Hive - Alter TableIn Hive, we can perform modifications in the existing table like changing the table name, column name, comments, and table properties. It provides SQL like commands to alter the table. Rename a TableIf we want to change the name of an existing table, we can rename that table by using the following signature: - Alter table old_table_name rename to new_table_name;
Alter table emp rename to employee_data;
Here, we got the desired output. Adding columnIn Hive, we can add one or more columns in an existing table by using the following signature: - Alter table table_name add columns(column_name datatype);
Alter table employee_data add columns (age int);
As we didn't add any data to the new column, hive consider NULL as the value. Change ColumnIn Hive, we can rename a column, change its type and position. Here, we are changing the name of the column by using the following signature: - Alter table table_name change old_column_name new_column_name datatype;
Alter table employee_data change name first_name string;
Delete or Replace ColumnHive allows us to delete one or more columns by replacing them with the new columns. Thus, we cannot drop the column directly.
alter table employee_data replace columns( id string, first_name string, age int);
Here, we got the desired output.
Next TopicPartitioning in Hive
|