From the course: Intermediate SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Common issues with the INSERT command - SQL Tutorial
From the course: Intermediate SQL: Data Reporting and Analysis
Common issues with the INSERT command
- [Teacher] Let's look at some common errors that happen when you insert data. As with the update command, the most common involve data types and violating constraints such as NOT NULL, UNIQUE, or key constraints. We're going to start with violating primary key constraints. Let's try inserting a row into the category table. Insert into the category table, category ID and name, values, one. New category. Now we're trying to give it a category ID of one which already exists. If you look in the table towards the right of your screen, the bottom rather, category ID one is assigned to action category currently. And where we try to insert that, it says, my sequel said, 1062 duplicate entry one for key primary. It's important to read and understand your errors. Primary key fields automatically check for uniqueness in most versions of SQL, and so the row was not inserted. if we'd specified a new value for category ID there…
Contents
-
-
-
-
-
-
(Locked)
INSERT rows into a table6m 28s
-
(Locked)
Common issues with the INSERT command7m 8s
-
(Locked)
Using MERGE instead of UPDATE/INSERT8m 40s
-
(Locked)
Duplicate table with SELECT5m 28s
-
(Locked)
Challenge: Insert a row into the film table37s
-
(Locked)
Solution: Insert a row into the film table1m 45s
-
(Locked)
-
-