From the course: AWS Certified Data Engineer Associate (DEA-C01) Cert Prep

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

SQL constraints

SQL constraints

- [Instructor] Relational databases prioritize maintaining data integrity. In this lesson we'll describe how we can define rules that our data must follow, and these are known as SQL constraints. We've already seen that when you create a new table, you define each column's name and data type. You can also add one or more constraints when defining a column. Constraints are used to maintain data integrity by enforcing certain rules on the columns. If a SQL command attempts to add data to a table or modify it in a way that would violate the constraint, then the command fails. The first type of constraint is not null. This will not allow the column to contain a null for the value. Default can help with this because it specifies a value to be used by default when no value is provided. Check specifies a condition that must be met by the column. For example, it always has to be greater than zero or less than or equal to 100. Unique requires that no values are repeated in the column. The…

Contents