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, 2019 in Big Data Hadoop by Karan
8,234 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, 2019 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
• 69,030 points
1,712 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, 2019 in Big Data Hadoop by anonymous

edited Jun 4, 2019 by Omkar 8,365 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
• 69,030 points
10,891 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
• 69,030 points
462 views
+1 vote
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,950 points
5,823 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,950 points
872 views
+1 vote
11 answers

hadoop fs -put command?

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

answered Dec 7, 2018 in Big Data Hadoop by Aditya
36,597 views
–1 vote
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,320 points
2,184 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, 2019 in Big Data Hadoop by Gitika
• 36,610 points
3,538 views
0 votes
1 answer

Hive: LOCATION and WITH DBPROPERTIES command in create table command

By default, the Hive database will be ...READ MORE

answered May 22, 2019 in Big Data Hadoop by Firoz
1,006 views