vfrank66
vfrank66

Reputation: 1458

How to execute schema(database) rename in Athena?

I am trying to execute a sql statement against Athena using sqlworkbench. I have executed several queries and know I have a connection if that is the first question. What would be the solution to renaming a database in Athena, or maybe Athena through the 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

My SQL syntax comes in Athena from Presto documentation which from my understanding is the syntax used by Athena.

8.1. ALTER SCHEMA Synopsis

ALTER SCHEMA name RENAME TO new_name

Upvotes: 2

Views: 4519

Answers (1)

Roberto
Roberto

Reputation: 847

Sorry but there is no way to rename a database in AWS Athena. Fortunately, table data and table definition are two completely different things in Athena.

You can just create a new database with the right name, generate all DDL's for your table and execute them using the new database.

The "new" tables in the new database will still pointing to the same location so nothing to worry about.

Upvotes: 4

Related Questions