简体   繁体   English

在 Athena AWS 中重命名列名

[英]Rename Column Name in Athena AWS

I have tried several ways to rename some column name in athena table.我尝试了几种方法来重命名 athena 表中的某些列名。

after reading the following article阅读以下文章后

https://docs.aws.amazon.com/athena/latest/ug/alter-table-replace-columns.html https://docs.aws.amazon.com/athena/latest/ug/alter-table-replace-columns.html

But I have get a no luck on it.但我没有运气。

I tried我试过了

ALTER TABLE "users_data"."values_portions" REPLACE COLUMNS ('username/teradata' 'String', 'username_teradata' 'String') 

Got error出现错误

no viable alternative at input 'alter table "users_data"."values_portions" replace' (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: 23232ssdds.....; proxy: null)

You can refer to this document which talks about renaming columns.您可以参考这篇关于重命名列的文档。 The query that you are trying to run will replace all the columns in the existing table with provided column list.您尝试运行的查询将用提供的列列表替换现有表中的所有列。

One strategy for renaming columns is to create a new table based on the same underlying data, but using new column names.重命名列的一种策略是基于相同的基础数据创建一个新表,但使用新的列名。 The example mentioned in the link creates a new orders_parquet table called orders_parquet_column_renamed. 链接中提到的示例创建了一个名为 orders_parquet_column_renamed 的新 orders_parquet 表。 The example changes the column o_totalprice name to o_total_price and then runs a query in Athena.该示例将o_totalprice列名称更改为o_total_price ,然后在 Athena 中运行查询。

Another way of changing the column name is by simply going to AWS Glue -> Select database -> select table -> edit schema -> double click on column name -> type in new name -> save .更改列名的另一种方法是简单地转到AWS Glue -> Select database -> select table -> edit schema -> double click on column name -> type in new name -> save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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