Change column datatypes in Hive database
9,842
You need to use the following ALTER TABLE
syntax:
ALTER TABLE table_name CHANGE column_name column_name newType
To break it down, you are:
- Making a change to the table:
ALTER TABLE
- Defining what table you are changing:
table_name
- Defining what column you will change:
CHANGE column_name
- Defining the change (you can also change column_name hence the double mention):
column_name newType
Related videos on Youtube
Comments
-
Nitesh B. over 1 year
Can I change the datatype in Hive database? Below is a complete information about the same.
I have a database named "test". It has a table "name". Below is a query I had used while creating a column in name table.
create table name(custID String,nameValuePairs array<struct< key:String, value:String>>) row format delimited fields terminated by '/' collection items terminated by '|' map keys terminated by '=' lines terminated by '\n';
Now, I would like to change the datatype entry of column name "nameValuePairs".
Currently the column
nameValuePairs
has datatypearray<struct< key:String, value:String>>
.Now I would like to change the datatype to
array<struct< something:somedatatype, value:String>>
.-
Jeff Schaller over 7 yearsSince this seems to be a sql question, see also dba.stackexchange.com
-