Column Modifiers
Written
Author
A column modifier is an extra addon command to help the database organize and work better.
As mentioned on the previous page, the integer types have an extra option called UNSIGNED. Normally, the integer goes from an negative to positive value. Using an UNSIGNED command will move that range up so it starts at zero instead of a negative number.
Other modifier commands are:
- INDEX
- UNIQUE
- PRIMARY KEY
- AUTO_INCREMENT
- NULL
- NOT NULL
- DEFAULT
- BINARY
- ZEROFILL
Indexing is a way to improve a database performance. You are telling the database that THIS specific column is special and may help organize the data. If there is a column you will be referring to often, it would probably be the best to be an INDEX column.
An INDEX column may have more than one cell holding the same data value. The two other index types are UNIQUE and PRIMARY KEY. UNIQUE states that each cell in the column should have a unique value. PRIMARY KEY is a special variety of the UNIQUE command.
The AUTO_INCREMENT modifier works on any of the integer types. Each time a new row is added into the database table, the number in this column will appear and automatically increase by one from the previous row.
NULL is no value. It is not space, it is not zero. A majority of the time you will want to specify a field to be NOT NULL so that any blank entries will be considered as "something".
DEFAULT will assign a default value to a cell if nothing is entered for the value. It will work on most data types except BLOB and TEXT.
BINARY is used with CHAR and VARCHAR types. It causes the values to be treated as "binary strings" making them CaSe SeNsItIvE.
ZEROFILL is used with numeric data types. It will display leading zeros of a number based on the display width.