SQL Constraints - Suja-dot/Database GitHub Wiki

NOT NULL

  • Indicated that column cannot contain any NULL value

'COLUMN1' 'DATA_TYPE(SIZE)' NOT NULL

UNIQUE

  • Does not allow to insert a duplicate value in a column
  • More than one UNIQUE column can be used in a table

PRIMARY KEY

  • Enforced the table to accept unique data for a specific column
  • for accessing the table faster

CHECK

  • Determined whether the value is valid or not from a logical expression

DEFAULT

  • While inserting data into a table, if no value is supplied to a column, then the column gets the value set as DEFAULT

AUTO INCREMENT

  • allow a unique number to be generated when a new record is inserted into a table
  • By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record

'COLUMN1' 'DATATYPE' NOT NULL AUTO_INCREMENT;