PostgreSQL中连字符( - )的转义序列是什么? [英] what's the escape sequence for hyphen (-) in PostgreSQL

查看:135
本文介绍了PostgreSQL中连字符( - )的转义序列是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用连字号( - )将数据库重命名为名称。

I'm trying to rename a database to a name with a hyphen (-).

ALTER DATABASE one RENAME TO one-two;

而且psql返回错误:

And psql returns an error:

ERROR:  syntax error at or near "-"

我使用 - 字符的转义序列,或者上述方法是什么?

What should I use as an escape sequence for "-" character or what's the way to do the above?

注意:
我尝试过'\- '并且没有工作。

Note: I've tried the '\-' and didn't work as well.

谢谢。

推荐答案

Double quotes should do it. But you'll have to always use the quoted-identifier everywhere you reference the database.

ALTER DATABASE one RENAME TO "one-two";

这篇关于PostgreSQL中连字符( - )的转义序列是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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