Replace Column names and datatype in Hive

0 votes
Hi. Can someone tell me how I can replace the name and datatype of a column in Hive table? I have some data in that column of datatype INT and want to change the name of this column, and datatype to STRING. So if I replace the name, will the data still exist or will it be erased?
May 21 in Big Data Hadoop by Karan
119 views

1 answer to this question.

0 votes

You can replace the column name and the datatype using the ALTER command. 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. 

answered May 21 by John

Related Questions In Big Data Hadoop

0 votes
1 answer

Hadoop: How to get the column name along with the output in Hive?

You can get the column names by ...READ MORE

answered Nov 20, 2018 in Big Data Hadoop by Omkar
• 67,600 points
339 views
0 votes
2 answers

How to get column names from Hive table?

To get all the columns of a ...READ MORE

answered Jun 4 in Big Data Hadoop by anonymous

edited Jun 4 by Omkar 2,369 views
0 votes
1 answer

How to replace characters in string in hive?

You can do it using regexp_replace. This is ...READ MORE

answered Nov 29, 2018 in Big Data Hadoop by Omkar
• 67,600 points
4,334 views
–1 vote
1 answer

Beeline and Hive Query Editor in Embedded mode

Running Hive client tools with embedded servers ...READ MORE

answered Dec 31, 2018 in Big Data Hadoop by Omkar
• 67,600 points
255 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,690 points
3,099 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,690 points
349 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
15,208 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,260 points
1,128 views
0 votes
1 answer

How to add column inside a table in Hive?

Hi, Yes, we can add column inside a ...READ MORE

answered May 15 in Big Data Hadoop by Gitika
• 25,340 points
35 views
0 votes
1 answer