postgres 重命名数据库不起作用 [英] postgres rename database not working

查看:76
本文介绍了postgres 重命名数据库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<前>bin]# ./createdb cx123 -U postgres[bin]# ./createdb cx111 -U postgres[bin]# ./psql -d cx123 -U postgres 欢迎使用 psql 8.3.7,PostgreSQL 交互式终端.键入:\copyright 用于分发条款 \h 用于 SQL 命令的帮助 \?有关 psql 命令的帮助 \g 或以分号终止以执行查询 \q 退出cx123=# ALTER DATABASE cx111 重命名为 cx222cx123-# \q[bin]# ./psql -l -U postgres数据库列表姓名 |业主 |编码-----------+----------+---------CX111 |postgres |UTF8cx123 |postgres |UTF8(2 行)################################################

大家好,看上面的代码,我没能将cx111重命名为cx 222,知道吗?非常感谢.

解决方案

您需要用分号终止 ALTER 语句.

你输入的方式,它永远不会被执行,因为 psql 正在等待语句完成.

bin]# ./createdb cx123 -U postgres
[bin]# ./createdb cx111 -U postgres

[bin]# ./psql -d cx123 -U postgres Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit

cx123=# ALTER DATABASE cx111 RENAME TO cx222
cx123-# \q

[bin]# ./psql -l -U postgres
List of databases
Name  | Owner    | Encoding
-----------+----------+---------- 
cx111 | postgres | UTF8
cx123 | postgres | UTF8
(2 rows)
###################################################

Hi guys, See the above code, I failed to rename cx111 to cx 222, any idea? Thanks a lot.

解决方案

You need to terminate the ALTER statement with a semicolon.

The way you typed it, it never got executed because psql was waiting for the statement to be finished.

这篇关于postgres 重命名数据库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆