0
0
SQLquery~5 mins

Common INSERT errors and fixes in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What causes the error "Column count doesn't match value count" in an INSERT statement?
This error happens when the number of columns listed in the INSERT statement does not match the number of values provided. To fix it, make sure the number of columns and values are the same.
Click to reveal answer
beginner
Why do you get a "NULL value in column violates not-null constraint" error during INSERT?
This error occurs when you try to insert a NULL value into a column that does not allow NULLs. To fix it, provide a valid value for that column or allow NULLs if appropriate.
Click to reveal answer
intermediate
What does a "duplicate key value violates unique constraint" error mean in an INSERT?
It means you are trying to insert a value that already exists in a column or set of columns that must be unique. To fix it, insert a unique value or remove the duplicate constraint if suitable.
Click to reveal answer
beginner
How to fix the error "Data type mismatch" in an INSERT statement?
This error happens when the value you try to insert does not match the column's data type. Fix it by converting the value to the correct type or correcting the value format.
Click to reveal answer
intermediate
What causes a "foreign key constraint fails" error during INSERT?
This error occurs when you insert a value in a foreign key column that does not exist in the referenced table. Fix it by inserting a valid existing key or adding the referenced record first.
Click to reveal answer
What should you check if you get a "Column count doesn't match value count" error?
AForeign key values exist
BData types of columns
CNumber of columns and values in INSERT must be equal
DTable name spelling
Which error occurs if you insert NULL into a NOT NULL column?
ANULL value violates not-null constraint
BDuplicate key error
CData type mismatch
DForeign key constraint fails
How to fix a "duplicate key value violates unique constraint" error?
ARemove all rows
BInsert NULL
CChange table name
DInsert a unique value
What causes a "foreign key constraint fails" error?
AInserting a value not present in the referenced table
BInserting NULL in any column
CMismatch in column count
DWrong table name
What is a common fix for a data type mismatch error in INSERT?
AInsert NULL
BConvert value to correct data type
CAdd more columns
DDelete the table
Explain common causes of errors when using INSERT statements and how to fix them.
Think about what the database expects for each column and how your values match those expectations.
You got /5 concepts.
    Describe how to troubleshoot and fix a foreign key constraint error during an INSERT.
    Foreign keys link tables; the value must exist in the linked table.
    You got /3 concepts.