18.2.9 Declare fields NOT NULLThis is NOT the latest copy of this book; click here for the latest version.
Each time you declare a field, MySQL needs one extra bit of data to store whether or not the value is NULL. This is because NULL is not 0, or indeed any value, so the only way for MySQL to know whether a value is NULL or not is to use this special bit.
If you know for a fact that a column will not be NULL, declare it as NOT NULL - this will allow you to save the bit, and stop MySQL from checking that bit every time it checks the value. For example:
CREATE TABLE MyNotNull (ID INT NOT NULL, Name CHAR(20) NOT NULL);
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|