且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除配置单元表中的列

更新时间:2023-12-01 13:29:10

我们不能简单地使用下面的语句(如sql)从配置单元表中删除表列.

We can’t simply drop a table column from a hive table using the below statement like sql.

ALTER TABLE tbl_name删除列column_name ----将不起作用.

ALTER TABLE tbl_name drop column column_name ---- it will not work.

因此,有一种从配置单元表中删除列的快捷方式.

So there is a shortcut to drop columns from a hive table.

假设我们有一个蜂巢表.

Let’s say we have a hive table.

我要从该表中删除Dob列.您可以使用ALTER TABLE REPLACE语句删除列.

From this table I want to drop the column Dob. You can use the ALTER TABLE REPLACE statement to drop a column.

ALTER TABLE test_tbl REPLACE COLUMNS(ID STRING,NAME STRING,AGE STRING);   you have to give the column names which you want to keep in the table