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 ROWSto limit the results set - Use
CASEorMERGEinstead ofUNION ALL
