DB2 Query Writing Best Practices

Problem

Writing efficient SQL SELECTqueries for DB2 can be tricky. Some general SQL guidelines apply, and there are also specific practices that apply only to DB2.

Solution

Here is a list of tips you can use to write good SELECT queries:

  • Avoid SELECT * in your queries. Instead, state the columns you want to select.
  • Use the consistent acronyms to alias your table names (makes it easier to read joins)
  • Use FETCH ONLY x ROWS to limit the results set
  • Use CASE or MERGE instead of UNION ALL

References

This entry was posted in DB2 and tagged , , , , , . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.