Q&A
Ask and answer questions to make information more available to wider audiences.
Lily Jarvi @jarvilily   14, Jun 2023 12:00 AM
change column data type in Hive
How to change the column data type in Hive?
answers 2
 
Answer 1
Michaela Samuel @samuelmichaela5   21, Jun 2023 11:15 AM
Example:

‘Intellipaat’ RLIKE ‘tell’ à True
‘Intellipaat’ RLIKE ‘^I.*’ à True (this is a regular expression)

 
Answer 2
Michaela Samuel @samuelmichaela5   21, Jun 2023 11:14 AM
We can change the column data type by using ALTER and CHANGE as follows:

ALTER TABLE table_name CHANGE column_namecolumn_namenew_datatype;

For example, if we want to change the data type of the salary column from integer to bigint in the employee table, we can use the following:

ALTER TABLE employee CHANGE salary salary BIGINT;

RLIKE: Its full form is Right-Like and it is a special function in Hive. It helps examine two substrings, i.e., if the substring of A matches with B, then it evaluates to true.