Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive: Is it possible to rename an existing hive database?

There seems to be a similar requirement at: https://issues.apache.org/jira/browse/HIVE-4847

However, when I tried the proposed syntax from the issue's Description - 'ALTER DATABASE dbname RENAME TO newdbname', it gave me the following error:

ALTER DATABASE testdb RENAME TO testdb1;

NoViableAltException(26@[])
    at org.apache.hadoop.hive.ql.parse.HiveParser.alterDatabaseStatementSuffix(HiveParser.java:7881)
    at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatement(HiveParser.java:6588)
    at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2183)
    at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1392)
    at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1030)
    at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
    at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
    at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:414)
    at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:332)
    at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:988)
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1053)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:924)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:914)
    at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:269)
    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:221)
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:431)
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:367)
    at org.apache.hadoop.hive.cli.CliDriver.processReader(CliDriver.java:464)
    at org.apache.hadoop.hive.cli.CliDriver.processFile(CliDriver.java:474)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:756)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:694)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:633)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 3:15 cannot recognize input near 'testdb' 'RENAME' 'TO' in alter database statement
like image 733
activelearner Avatar asked Apr 06 '15 23:04

activelearner


People also ask

Can a database be renamed?

In Object Explorer, expand Databases, right-click the database to rename, and then select Rename. If the database was your default database, see Reset your default database after rename.

How do I change the Hive database?

By default, hive stores its data at /user/hive/warehouse on HDFS. DESCRIBE DATABASE EXTENDED student; Step 2: Use ALTER to change the parent-directory location (NOTE: /hive_db is the available directory on my HDFS ).

How do I find my Hive database name?

To list out the databases in Hive warehouse, enter the command 'show databases'.


1 Answers

Current Apache hive release doesn't support this feature. In this apache Hive Jira HIVE-4847, you can see this is a new feature and the patch is available but it is yet to be merged and tagged to a particular release. We can expect this feature in any of the later releases.

like image 190
SachinJ Avatar answered Dec 12 '22 00:12

SachinJ