SQL Constraints, Learn SQL, Codecademy, Manipulation

Lesson Summary

Constraints allow us to specify how a column can be used. A constraint will tell the database to either accept or reject inserted data when it does not adhere to a certain type of restriction(constraint). We look at last lessons create table command. "CREATE TABLE celebs ( id INTEGER PRIMARY KEY, name TEXT UNIQUE, date_of_birth TEXT NOT NULL, date_of_death TEXT DEFAULT 'Not Applicable');" "PRIMARY KEY" column can be utilized to identify uniquely a row. When an identical row is attempted to be inserted, a constrain violation will not allow the new row to be inserted. "UNIQUE" columns must have a different value every row. The "NOT NULL" constraint tells our database that this column must always have a value. If a value is not given, a constraint violation will prohibit the row from being inserted. "DEFAULT" columns will take an argument additionally that will be an assumed value for a row, if a value is not specified.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required