Chapter 7. Columns

When you're defining a column, the first question you should ask is—What data is possible or impossible for this column? For example, a “phone number” column should accommodate all possible phone numbers but no impossible ones; a “book title” column should accommodate uppercase conversion but not addition. Your second question should be—Given the answer to the first question, what data type is both efficient and portable for this column? For example, an elapsed-minutes column might be defined as INTEGER rather than INTERVAL because INTEGER is smaller and is more easily cast to a C data type.

This chapter is all about how you can choose the data type and size for a column without growing dependent on any DBMS's foibles. After ...

Get SQL Performance Tuning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.