DB2 Basics: Capitalization

You may also like...

3 Responses

  1. Andres Gomez says:

    Hi,

    Very good article! And I would like to say that the problem is even worse when you have to deal with these case-sensitive tables from DB2CLP.

    I asked and solved a question in StackOverFlow that tries to solve this problem: http://stackoverflow.com/questions/12937463/how-to-access-tables-with-same-name-different-case-in-db2

    Andres Gomez (AngocA)

  2. Steve Bailey says:

    I like to use UPPER CASE for keywords, lower case for columns and Start Case for other objects in the database. Abbreviations are not capitalised in column names, but are in the other object names. I also use underscores between words and numbers (unless aliasing a table).

    This is a style I have adopted and modified form Joe Celko’s SQL Programming Style book.

    I find the different case usage makes it easier to read and locate the different parts of the SQL statement (clauses, objects and columns)
    Indentation also has a huge part to play in readability but that’s a different subject altogether.

    Example of capitalisation (not indentation)…

    SELECT T1.my_column_1, T2.my_column_2
    FROM My_First_Table AS T1
    INNER JOIN My_Second_Table AS T2
    ON T1.my_column_1 = T2.my_column_1
    WHERE T1.my_column_2 = ‘some value’;

  1. April 15, 2014

    […] DB2 Basics: Capitalization […]

Leave a Reply

Your email address will not be published. Required fields are marked *