From the course: Microsoft SQL Server 2019 Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Unique constraints - SQL Server Tutorial
From the course: Microsoft SQL Server 2019 Essential Training
Unique constraints
- [Narrator] There are any number of reasons why you would want to enforce values in a record to be unique from all the other records in the table. The table's primary key column is just one example of a column that needs to maintain unique values. It's probably a bad idea to have two different products with exactly the same name because that would make it confusing for customers that are trying to place an order, or maybe you want to use email addresses as a way to identify individual people when posting reviews on a recipe website. We can have SQL Server monitor the values that are being stored in our data tables and by identifying individual columns that should not allow duplicate values between records, we can have the server enforce this rule on the data. In the Landon Hotel employees table, we have a column that's storing our email addresses for the company. We can see that by right-clicking on it and choosing…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Understand data types6m 46s
-
Table column properties4m 7s
-
(Locked)
Primary key fields3m 46s
-
(Locked)
Establish a default value4m
-
(Locked)
Check constraints4m 7s
-
(Locked)
Unique constraints5m 39s
-
(Locked)
Foreign keys3m 59s
-
(Locked)
Create a foreign key column3m 30s
-
(Locked)
Create relationships between tables4m 19s
-
(Locked)
-
-
-
-
-
-
-