How do I create a table with PascalCase notation in Amazon Redshift? - 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.

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...

DB2 UnLOAD in unicode with two chardelimiter

I have to create an UNLOAD job for a DB2 table and save the UNload in unicode. That's no problem.
But unfortunately there are contents in the table columns that correspond to the separators.
For example, I would like the combination #! as a separator, but I can't do that in unicode.
Can someone tell me how to do this?
Now my statement looks like this:
DELIMITED COLDEL X'3B' CHARDEL X'24' DECPT X'2E'
UNICODE
thanks a lot for your help
The delimiter can be a single character (not two characters, as you want).
In this case the chosen solution was to find a single character that did not appear in the data.
When that is not possible, consider a non-delimited output format, or a different technique to get the data to the external system (for example via federation or other SQL-based interchange, or XML etc.

Normalize human names in postgresql

What is the easiest way to normalize a text field in postgresql table?
I am trying to find duplicates.
For example, I want to consider O'Reilly a duplicate of oreilly. La Salle should be a duplicate of la'salle as well.
In a nutshell, we want to
lowercase all text,
strip accents
strip punctuation marks such as these [.'-_] and
strip spaces
Can this all be done in one or two simple steps? Ideally using built in postgresql functions.
Cheers
The following will give you what you want, using just standard Postgres functions;
regexp_replace (lower(unaccent(string_in)),'[^0-9a-z]','','g')
See example here. Or if you do not want digits the just
regexp_replace (lower(unaccent(string_in)),'[^a-z]','','g')

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.

Unable to import table with Camel Case naming convention

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.