省略双引号对 PostgreSQL 进行查询 [英] Omitting the double quote to do query on PostgreSQL

查看:17
本文介绍了省略双引号对 PostgreSQL 进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题,有什么办法可以省略PostgreSQL中的双引号?

Simple question, is there any way to omit the double quote in PostgreSQL?

这是一个例子,给 select * from A;,我将检索 ERROR:relation "a" does not exist,我将不得不给 select * from "A"; 得到真实结果.

Here is an example, giving select * from A;, I will retrieve ERROR: relation "a" does not exist, and I would have to give select * from "A"; to get the real result.

在 PostgreSQL 上有没有办法不做第二个而是做第一个?

Is there any way not to do the second and instead do the first on PostgreSQL?

推荐答案

此查询的问题始于您创建表时.创建表格时,请勿使用引号.

Your problem with this query started when you created your table. When you create your table, don't use quotes.

使用这个:

CREATE TABLE a ( ... );

不是这个:

CREATE TABLE "A" ( ... );

后者会让你以后总是不得不引用它.前者使其成为普通名称,您可以使用 SELECT * FROM a;SELECT * FROM A;

The latter will make it so that you always have to quote it later. The former makes it a normal name and you can use SELECT * FROM a; or SELECT * FROM A;

如果您不能只是重新创建表,请使用 ALTER TABLE 语法:

If you can't just recreate your table, use the ALTER TABLE syntax:

ALTER TABLE "A" RENAME TO a;

这篇关于省略双引号对 PostgreSQL 进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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