Case sensitivity in postgresql

Use this forum for questions and answers regarding PostGreSQL and the PGDBE.
Post Reply
Message
Author
User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Case sensitivity in postgresql

#1 Post by unixkd »

Hi all

How can I set case sensitivity off in postgresql

Thanks

Joe

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Case sensitivity in postgresql

#2 Post by rdonnay »

Column names in SQL statements are NOT case sensitive.

Please clarify what you are asking.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: Case sensitivity in postgresql

#3 Post 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

Post Reply