error when counting rows from postgresql database

If you have capitals in the table/column names, use double quotes, not back ticks. "Doc"."Headers"

In C#, you’d have to escape a second set of double quotes. This can be done a few ways.

// if using `@`
string x = @"select * from ""Doc"".""Headers"" ";

// if not using `@`
string y = "select * from \"Doc\".\"Headers\" ";

However, if you created the table using capitals without double quotes, Postgres should have lowered your names.

E.g.: create table DOCS would create a table actually called docs. To create it with capitals you would need create table "DOCS".

The one exception is if you use a program that does this for you. There was at least one version of pgAdmin that did this during creation. I have since learned my lesson and only use lowercase + underscores to avoid having to quote identifiers.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top