Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

Omitting the double quote to do query on PostgreSQL

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

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Use this:

CREATE TABLE a ( ... );

Not this:

CREATE TABLE "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;

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

ALTER TABLE "A" RENAME TO a;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...