The current schema is:
hive> describe tableA; OK id int ts timestamp
I want to change ts
column to be BIGINT
without dropping table and recreate again. Is it possible?
Refer to the command below: hive> ALTER TABLE <tablename> REPLACE COLUMNS (<old column name> INT, <new column name> STRING); This command will only change the schema of the table i.e., it will change the column name and the datatype but will not affect the data stored in the column.
The SQL ALTER TABLE command is used to add, delete or modify columns in an existing table.
In 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.
Found the solution:
ALTER TABLE tableA CHANGE ts ts BIGINT AFTER id;
See this for complete details: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AlterColumn
ALTER TABLE table_name CHANGE col_name col_name newType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With