Page 1 of 1
Case sensitivity in postgresql
Posted: Fri Feb 14, 2025 4:38 am
by unixkd
Hi all
How can I set case sensitivity off in postgresql
Thanks
Joe
Re: Case sensitivity in postgresql
Posted: Fri Feb 14, 2025 9:49 am
by rdonnay
Column names in SQL statements are NOT case sensitive.
Please clarify what you are asking.
Re: Case sensitivity in postgresql
Posted: Mon Feb 17, 2025 7:22 am
by unixkd
In PostgreSQL, table names and column names are case-sensitive, but with some caveats.
Table Names
By default, PostgreSQL converts table names to lowercase, unless they are quoted. This means that:
- `CREATE TABLE MyTable` will create a table named `mytable`.
- `CREATE TABLE "MyTable"` will create a table named `MyTable`.
Column Names
Similarly, column names are also case-sensitive, but they follow the same quoting rules as table names:
- `CREATE TABLE mytable (MyColumn integer)` will create a column named `mycolumn`.
- `CREATE TABLE mytable ("MyColumn" integer)` will create a column named `MyColumn`.
Best Practices
To avoid confusion and ensure portability, it's recommended to:
- Use lowercase table and column names.
- Avoid quoting table and column names, unless necessary.
- Use consistent naming conventions throughout your database.
By following these best practices, you can ensure that your PostgreSQL database is easy to work with and maintain.
Above from AI
Thanks