简体   繁体   English

无法重命名PostgreSQL数据库

[英]Can't rename PostgreSQL database

I'm using PostgreSql 9.2. 我正在使用PostgreSql 9.2。 Trying to do 尝试做

ALTER DATABASE 3_8_dev_test6 RENAME TO 3_8_dev_test

but get: 但得到:

ERROR:  syntax error at or near "3"
LINE 1: ALTER DATABASE 3_8_dev_test6 RENAME TO 3_8_dev_test

So what's wrong? 那怎么了

If the name really starts with a number then use double quotes 如果名称确实以数字开头,则使用双引号

ALTER DATABASE "3_8_dev_test6" RENAME TO "3_8_dev_test"

But then you will have to match the case also 但是那时候你也必须要匹配大小写

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Postgres assumes you're going to enter a number in this case so if you want to have numbers in the beginning of a name, use quotes :) Postgres假设您要在这种情况下输入数字,因此,如果您想在名称开头输入数字,请使用引号:)

In this case: 在这种情况下:

ALTER DATABASE "3_8_dev_test6" RENAME "TO 3_8_dev_test";

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

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