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

查看:717
本文介绍了省略双引号以在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天全站免登陆