Configuration – Configure PostgreSQL Column Capitalization for Flexible Querying

configurationpostgresql

I have an existing database that we need to replace from MySQL to PostgreSQL. The problem being that we currently have two applications that use the database (one to create and one to view the data) that use different capitalization.

As the viewing application is in php it will grab the data using the following:

$row["Data"]

But the column "Data" doesn't exist because PostgreSQL converts it to lowercase to there is only the column "data".

A solution to this would be to rewrite the database and use "Data" in the queries and make the queries case-sensitive. The only problem is that this would break the creating application as it uses the lowercase variant.

So the question is, if there is some kind of setting within PostgreSQL that would allow to use capitalization for the column names while having case-insensitive queries?

Best Answer

As documentation claims unquoted identifiers are case insensitive. If you see that the identifiers are case-sensitive, this means that your application (connection library?) adds identifiers quoting. Configure it properly. - akina

Is there some kind of setting within PostgreSQL that would allow to use capitalization for the column names while having case-insensitive queries?

You will have to modify at least one of your applications. There is no parameter in PostgreSQL that makes it "partly case sensitive". - laurenz-albe