Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2015
    Posts
    2

    Smile Unanswered: Is there a way to turn off case sensitivity of the postgresql ??

    Hi All,

    Is there a way to turn off case sensitivity of the postgresql so that I can use
    "select id, empname , sal from test " for convinience instead of
    "select ID,EmpName,Sal from Test".

    Can anyone explain why case sensitivity is required for table names and field names considering that we don't use two fields with same name in a table - one with Upper case and the other with Lower case.
    It is not intuitive making it case sensitive unless there is a strong reason to make it so.

    Regards
    DbSeeker

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Identifiers are not case sensitive unless you explicitly create them like that. The following works without problems:
    Code:
    create table TEST (Id integer, EmpName text, sal decimal(10,8);
    select ID, empname, SAL
    from Test;
    Here is an online example: http://sqlfiddle.com/#!15/7bbd2/1

    Identifiers are only case-sensitive when you enclose them in double quotes: "ID" is a different identifier than "Id".
    This is required by the SQL standard.

    For more details, please see the manual: http://www.postgresql.org/docs/curre...AX-IDENTIFIERS
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by dbseeker View Post
    Hi Shammat, but "create table TEST (Id integer, EmpName text, sal decimal(10,8)) " would create empname and not EmpName which is more intuitive and clear.
    To create EmpName we need to put this in quotes but any upper case character in the identifier tends to trouble in Pentaho Data Integration.
    Well, you asked about case insensitive identifiers, not case preserving storage.

    This is how the SQL standard requires it - with the exception that the standard requires unquoted names to be stored in upper case not lower case. In SQL using CamelCase is not very common and quoted identifiers should be avoided at all cost. Most people just use underscores to delimit the words: emp_name rather than empname.

    But because identifiers are case insensitive, no one keeps you from writing EmpName all the time. The way it's stored in the database doesn't matter for your SQL code.
    Last edited by shammat; 04-19-15 at 10:57.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •