如何在 Athena 中执行模式(数据库)重命名?

How to execute schema(database) rename in Athena?

我正在尝试使用 sqlworkbench 对 Athena 执行 sql 语句。我已经执行了几个查询,如果这是第一个问题,我知道我有连接。在 Athena 或 Athena 中通过 jdbc 重命名数据库的解决方案是什么?

alter schema geoosm rename to geo_osm

An error occurred when executing the SQL command: alter schema geoosm rename to geo_osm

[Simba]AthenaJDBC An error has been thrown from the AWS Athena client. line 1:24: mismatched input 'rename' expecting 'SET' [Execution ID not available] [SQL State=HY000, DB Errorcode=100071] 1 statement failed.

Execution time: 0.27s

我的 SQL 语法来自 Athena from Presto documentation,根据我的理解,这是 Athena 使用的语法。

8.1. ALTER SCHEMA Synopsis

ALTER SCHEMA name RENAME TO new_name

抱歉,无法在 AWS Athena 中重命名数据库。幸运的是,table数据和table定义在Athena中是两个完全不同的东西。

您只需创建一个具有正确名称的新数据库,为您的 table 生成所有 DDL,然后使用新数据库执行它们。

新数据库中的 "new" table 仍将指向相同的位置,因此无需担心。