Hive:是否可以重命名现有的 Hive 数据库?
Hive: Is it possible to rename an existing hive database?
似乎有类似的要求:https://issues.apache.org/jira/browse/HIVE-4847
但是,当我尝试问题描述中建议的语法时 - 'ALTER DATABASE dbname RENAME TO newdbname',它给了我以下错误:
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
当前的 Apache 配置单元版本不支持此功能。在此 apache Hive Jira HIVE-4847 中,您可以看到这是一项新功能,补丁可用,但尚未合并并标记为特定版本。我们可以期待在以后的任何版本中都有此功能。
似乎有类似的要求:https://issues.apache.org/jira/browse/HIVE-4847
但是,当我尝试问题描述中建议的语法时 - 'ALTER DATABASE dbname RENAME TO newdbname',它给了我以下错误:
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
当前的 Apache 配置单元版本不支持此功能。在此 apache Hive Jira HIVE-4847 中,您可以看到这是一项新功能,补丁可用,但尚未合并并标记为特定版本。我们可以期待在以后的任何版本中都有此功能。