08/09: MySQL > Column Attributes
Category: Study
Posted by: hajime osako
- For numeric columns:
- UNSIGNED
- ZEROFILL (causes UNSIGNED)
- AUTO_INGREMENT (may be only one per table, and must be indexed, and must be defined as NOT NULL)
LAST_INSERT_ID() returns the most recently generated AUTO_INCREMENT value.
If you update an AUTO_INCREMENT column to NULL or 0, the column is set to 0.
By default, inserting 0 in an AUTO_INCREMENT column has the same effect as inserting NULL unless the NO_AUTO_VALUE_ON_ZERO SQL mode is enabled.
MyISAM storage engine supports composite indexes. In composite indexes, AUTO_INCREMENT value could be reused. - ZEROFILL (causes UNSIGNED)
- For string columns:
- CHARACTER SET (= CHARSET) ex. utf-8
- COLLATE (if CHARSET is omitted, set to the collation's character set.)
- BINARY
- COLLATE (if CHARSET is omitted, set to the collation's character set.)
- For general columns:
- NOT NULL
- DEFAULT value (can't use for TEXT, BLOB and AUTO_INCREMENT (integer) columns)
- A default value must be a constant except CURRENT_TIMESTAMP for one TIMESTAMP column.
- Implicit default values are:
0 for numeric columns
"" for string columns except ENUM
the first enumeration member for ENUM
zero value for temporal columns
- DEFAULT value (can't use for TEXT, BLOB and AUTO_INCREMENT (integer) columns)