Field naming conventions using SQL server or other main frame databases

Posted on 2007-07-19
Last Modified: 2008-02-01
What is the advantage (if any) of naming fields in a main frame database i.e. Sql Server, Oracle, etc. upper case vs. lower case or conventional case (MyField)? We have a rather arrogant young engineer trying to convince me it makes a difference. We currently use all upper case. He suggests conventional case. Does it really make a difference??
    LVL 92

    Assisted Solution

    by:Patrick Matthews
    On SQL Server it makes no difference.  That said, I find all upper and all lower harder to read.
    So, out of:


    I would prefer the last, but that is just a personal preference :)
    LVL 28

    Accepted Solution

    I can tell you that Pervasive.SQL also ignores case.  I believe that the SQL language in general (at least for anyone following the ANSI standards) is case INSENSITIVE for all table names, field names, index names, etc.  

    Personally, I also prefer mixed case, capitalizing each word, which makes it easier to read.  Sometimes, it DOES make a different, as a Product Maintenance Switch field, labelled PMSWITCH, can be read in two different ways depending on the day.  ;-)

    The same can be said for the SQL keywords -- these are also case insensitive.  However, readability does start to come into play if you are flexible with whitespace, too.  It is one reason why I like to use all caps for SQL keywords, and mixed case for tables and columns.  This makes it easier to read queries in a hurry. (Do you ever have time to read them slowly?)

    Imagine a strange query, pulling the "Select" field from the "From" table, which in all caps looks like:
    or, with mixed case:
        SELECT Select FROM From
    OK, so the names are a bit contrived, but in larger queries, I think you'll see a huge difference in readability.

    So, in short, it does not matter which case you use to the computer -- but it might make a difference to the human trying to read it later on.
    LVL 42

    Assisted Solution

    Some databases are case-sensitive--even SQL server can be installed/configured that way.  And it's a real pain when you encounter one.  So, if you are working on a case-senstive DB, then it is very important to use an uppercase/lowercase/mixed case standard consistently.  If the database is not case sensitive, then its a matter of style and will not effect outcome of queries.  That said, a following a standard can add to readability and can help make code more self-documenting.  

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Introduction If you are not already aware of what you could use a table with sequential integer values for in SQL, you can read Delimited String Parsing in SQL Server 2005 or later ( by BrandonGalderisi (h…
    Creating and Managing Databases with phpMyAdmin in cPanel.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now