Style Notes
When you execute several SQL statements sequentially, it's important to use a consistent style. For example, instead of running these two SQL statements:
SELECT column1*4 FROM Table1 WHERE COLUMN1 = COLUMN2 + 7 select Column1 * 4 FROM Table1 WHERE column1=(column2 + 7)
run these two statements:
SELECT column1 * 4 FROM Table1 WHERE column1 = column2 + 7 SELECT column1 * 4 FROM Table1 WHERE column1 = column2 + 7 GAIN: 2/8
"But there's no difference!" you may exclaim. Well, semantically all four SELECTs are the same. The trick, though, is that some DBMSs store parsed results from previous queries and will reuse them if the queries are precisely the sameincluding spaces and capitalization. So a firm, consistent style will not only make SQL statements easier to readit just might make them run faster!
We're not going to give you a style guide here because that's not the purpose of this book. But we will observe that the transform in the example used some common and easy-to-remember rules:
Keywords uppercase but column names lowercase.
Table names initial capitalized.
Single spaces around each word and around each arithmetic operator.