Optional Attributes
Go Up to Defining Columns
You have the option to specify:
- A default value for the column.
- Integrity constraints. Constraints can be applied to a set of columns (a table-level constraint), or to a single column (a column-level constraint). Integrity constraints include:
- The
PRIMARY KEYcolumn constraint, if the column is aPRIMARY KEY, and thePRIMARY KEYconstraint is not defined at the table level. Creating aPRIMARY KEYrequires exclusive database access. - The
UNIQUEconstraint, if the column is not aPRIMARY KEY, but should still disallow duplicate andNULLvalues. - The
FOREIGN KEYconstraint, if the column references aPRIMARY KEYin another table. Creating aFOREIGN KEYrequires exclusive database access. The foreign key constraint includes theON UPDATEandON DELETEmechanisms for specifying what happens to the foreign key when the primary key is updated (cascading referential integrity).
- The
- A
NOT NULLattribute does not allowNULLvalues. This attribute is required if the column is aPRIMARY KEYorUNIQUEkey. - A
CHECKconstraint for the column. ACHECKconstraint enforces a condition that must be true before an insert or an update to a column or group of columns is allowed. - A
CHARACTER SETcan be specified for a single column when you define the data type. If you do not specify a character set, the column assumes the database character set as a default.