Unable to import table with Camel Case naming convention - postgresql

i am working with PostgreSQL database. I have my all tables following camel case naming convention for columns. How to use same structure with PostgreSQL>

All identifiers (including column names) that are not double-quoted are folded to lower case in PostgreSQL.
Column names that were created with double-quotes and thereby retained upper-case letters (and/or other syntax violations) have to be double-quoted for the rest of their life.
So, in PostgreSQL column names are case-sensitive depending on the way they are created.
I recommend you to create column names in lower case so that you can query them the way you prefer.

Related

PostgreSQL SELECT can alter a table?

So I'm new to SQL like databases and the place that I work at migrated to PostgreSQL. One table drastically reduced its contents. The point is, I only used SELECT statements, and changed the name of the columns with AS. Is there a way I might have changed the table data?
When you migrate from a DBMS to another DBMS you must be sure that the objects created are strictly equivalent... The question seems to be trivial, but is'nt.
As a matter fact one important consideration for litterals (char/varchar...) is to verify the collation used formerly and the collation you have used to create the newly database in PostGreSQL.
Collation in an RDBMS is the way to adjust the behavior of character strings with regard to certain parameters such as the distinction, or not, of upper and lower case letters, the distinction, or not, of diacritical characters (accents, ligatures...), specific sorting to language, etc. And constitutes a superset of the character encoding.
Did you verify this point when using some WHERE clause to search some litterals ? If not, try to restricts litteral in applying the right collation (COLLATE operator) or use UPPER function to avoid the distinguish between upper and lower chars...

ServiceStack.Ormlite Postgres case insensitive queries

I am looking to cleanly implement a mechanism to override all where clauses that compare strings to do the following
[Column].Value.ToLower() == SqlParam.ToLower()
effectively overcoming the case sensitivity of Postgres.
OrmLite's INamingStrategy allows you to customize how Schemas, Tables and Columns are named and OrmLite's PostgreSQL Provider is already configured to use the PostgreSqlNamingStrategy which converts or .NET's PascalCase names to PostgreSQL-friendly snake_case.

When do Postgres column or table names need quotes and when don't they?

Let's consider the following postgres query:
SELECT *
FROM "MY_TABLE"
WHERE "bool_var"=FALSE
AND "str_var"='something';
The query fails to respond properly when I remove quotes around "str_var" but not when I do the same around "bool_var". Why? What is the proper way to write the query in that case, no quotes around the boolean column and quotes around the text column? Something else?
PostgreSQL converts all names (table name, column names etc) into lowercase if you don't prevent it by double quoting them in create table "My_Table_ABC" ( "My_Very_Upper_and_Lowercasy_Column" numeric,...). If you have names like this, you must always double quote those names in selects and other references.
I would recommend not creating tables like this and also not using chars outside a-z, 0-9 and _. You can not guarantee that every piece of software, library etc ever to be used against your database will support case-sensitivity. It's also tedious to remember and doing this double quoting.
Thanks to #TimBiegeleisen's comment, I was able to pinpoint the problem; I used a reserved keyword ("user") as a column name.
Link to reserved keywords in the doc: https://www.postgresql.org/docs/current/sql-keywords-appendix.html.
Now I know not to use quotes to query column names, but rather to avoid reserved keywords as column names.

How do I create a table with PascalCase notation in Amazon Redshift?

I want to create a table in Amazon Redshift with PascalCase notation. How do I achieve this?
E.g.: I want the table name to be "EmployeeDetails" and not as default way in which it gets created as "employeedetails".
Identifiers and names in Redshift are case-insensitive.
Standard and delimited identifiers are case-insensitive and are folded
to lower case. Identifiers must consist of only UTF-8 printable
characters.
Source
I recommend using snake_case, as #a_horse_with_no_name suggested. This is the standard way of doing it.

jdbc : postgres and quoted column names

Is there any way to determine in JDBC that a column or table has been created using "" notation? The metadata get columns does not seem to return such information.
PS: our customer model has been unfortunately created in such a way :-(
If the column name is returned in mixed case or all upper then it has been created using quotes.
So if columnName.equals(columnName.toLowerCase()) == true then no quotes were used. Or to be more prices: no quotes are needed.
Note that this is Postgres specific. Other databases store unquoted names in uppercase, some store them "as-is" without requiring quotes.