From the course: Microsoft SQL Server 2022 Essential Training
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
Primary key fields - SQL Server Tutorial
From the course: Microsoft SQL Server 2022 Essential Training
Primary key fields
- [Instructor] If I open the Red30 Tech customers table in the design tool again, we'll see that we now have the customer ID column created that's automatically generating unique identifiers for each customer that we enter into the table. Because unique record identifiers are so core to the functionality of a relational database, we can take the concept one step further and tell SQL Server that even though there may be other columns in the table that store unique values, this column in particular is the most important. We do this by designating the column as the table's primary key. To see what this means, let's go ahead and open up the customer's data. I'll right click on it and choose select top 1000 rows. Now, the reason we designate a primary key column is so that we can know without a doubt that we will always have a way of finding specific records of interest. If we were to search through our customer's table by the…
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
-
-
-
-
-
-
Choose appropriate data types2m 46s
-
(Locked)
SQL Server data type options7m 19s
-
(Locked)
Automatically assign record identities4m 54s
-
(Locked)
Primary key fields4m 35s
-
(Locked)
Establish a default value5m 1s
-
(Locked)
Check constraints5m 10s
-
(Locked)
Unique constraints6m 23s
-
(Locked)
Foreign keys4m 16s
-
(Locked)
Create a foreign key column5m 16s
-
(Locked)
Create relationships between tables5m 6s
-
-
-
-
-
-
-