说明
Unfortunately, you can’t! (很不幸,不能这么操作)
The only way you can delete column from existing table is by using REPLACE COLUMNS keyword.
But this can be done only for tables with a native SerDe
(DynamicSerDe, MetadataTypedColumnsetSerDe, LazySimpleSerDe and ColumnarSerDe).
Your best bet is recreating the schema. Follows the steps.(建议重新建Schema)
-
Check if the table is external. If it isn’t, use the following statement to make it external.
-
alter table alpha001 set tblproperties(‘EXTERNAL’=‘TRUE’);
Drop the table. Since the table is an external table, you can drop it without dropping the actual table. -
Recreate the table with the new schema. You should be able to access the table with new schema.
解决例子
原始表结构
create external table if not exists ods_mysql.ods_db_o2m__tb_time_period_dict (
`id` bigint comment "自增ID",