IBMi DB2 File/Table field naming convention – More than 10 character abbreviations!

Are you tired of being stuck to 10 Upper Case characters for field names?

Well before you start changing your current naming convention you’ll want to make sure the others you work with are cool with your idea for naming conventions.  People will need to realize the differences between a SQL (strsql,PHP (db2_*)) and System perspective (dbu, query, etc…).    There’s really 3 scenarios for naming fields:

1) Always use system naming 10 character uppercase.  This is best for applications where RPG and PHP will both be accessing the table.  Keeps both developers on the same page
MYCOLTHATS DECIMAL(9, 0) DEFAULT NULL ,

2) Use SQL Name and System name all uppercase
MYCOLTHATSLONG FOR COLUMN MYCOLTHATS DECIMAL(9, 0) DEFAULT NULL ,

3) Use SQL Name in mix case (camel case, all lower, etc…) and System name
“MyColThatsLong” FOR COLUMN MYCOLTHATS DECIMAL(9, 0) DEFAULT NULL ,

Tip:  use the “FOR COLUMN <system field name>” to specify a nice system name instead of an autogenerated system name like MYCOL00001.  If you do:

MYCOLTHATSLONG DECIMAL(9, 0) DEFAULT NULL ,

you’ll get

MYCOLTHATSLONG FOR COLUMN MYCOL00001 DECIMAL(9, 0) DEFAULT NULL ,

Example:

Gotcha Note: The actual “File Member” will have the ugly name with MYTAB00001

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s