简体   繁体   中英

Drop column in Impala

I want to drop the whole column 'index' (column name and values) in Impala:

index case_id customer_id
1 A xxx56

I used this code:

ALTER TABLE DBName.Tablename
DROP COLUMN index;

The result is like this:

case_id customer_id
1 A

How can I solve this?

Dropping a column with ALTER TABLE mytab DROP COLUMN col will alter only metadata and underlying data remains intact. Which means you got the columns shifted although data is intact.

Only solution is to backup, drop and recreate the table.

create table DBName.Tablename_tmp as select case_id,    customer_id from DBName.Tablename; -- just backup table with new structure.
drop table DBName.Tablename;
create table DBName.Tablename as select * from DBName.Tablename_stg;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM