Syntax
ALTER TABLE name REPLACE COLUMNS (col_spec[, col_spec ...])
Example
ALTER TABLE employee REPLACE COLUMNS ( emp_id INT, emp_name STRING);
Above snippet delete all the columns from the employee table and replaces it with emp_id, emp_name columns. You can use ‘REPLACE COLUMNS’ statement to delete a column.
hive> DESC employee;
OK
id int
name string
organization string Organization name in the compay
age int employee age
Time taken: 0.073 seconds, Fetched: 4 row(s)
hive> ;
hive> ;
hive> ALTER TABLE employee REPLACE COLUMNS (
> emp_id INT,
> emp_name STRING);
OK
Time taken: 0.088 seconds
hive> ;
hive> ;
hive> DESC employee;
OK
emp_id int
emp_name string
Time taken: 0.102 seconds, Fetched: 2 row(s)
No comments:
Post a Comment