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?
Quotes and double quotes should be escaped using \.
Use two single quotes to escape them in the sql statement. The double quotes should not be a problem: SELECT 'How is my son''s school helping him learn? "Not as good as Stack Overflow would!"'
In PostgreSQL, double quotes (like "a red dog") are always used to denote delimited identifiers. In this context, an identifier is the name of an object within PostgreSQL, such as a table name or a column name. Delimited identifiers are identifiers that have a specifically marked beginning and end.
select E 'Text\'Text'; Explanation: In the above syntax, we use a select statement but this syntax is applicable for old versions of PostgreSQL string constants with E and backslash \ to escape single quotes.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With