Recall & Review
beginner
What does the SQL INSERT statement do when specifying specific columns?
It adds new rows to a table by inserting values only into the specified columns, leaving other columns to their default values or NULL.
Click to reveal answer
beginner
Write the basic syntax of an INSERT statement with specific columns.
INSERT INTO table_name (column1, column2) VALUES (value1, value2);
Click to reveal answer
beginner
Why is it useful to specify columns in an INSERT statement?
It allows you to insert data only into certain columns, which is helpful if you don't have values for all columns or want to use default values for some.
Click to reveal answer
intermediate
What happens if you omit a column in the INSERT statement and it has no default value?
The database will raise an error because it expects a value for that column unless it allows NULL values.
Click to reveal answer
beginner
Example: Insert a new user with only 'name' and 'email' columns into a 'users' table.
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
Click to reveal answer
What is the correct way to insert data into only 'name' and 'age' columns of a 'people' table?
✗ Incorrect
Option D correctly specifies the columns and values. Option B omits columns, which may cause errors if the table has more columns. Option A has mismatched columns and values. Option C has wrong syntax.
If a column is not listed in the INSERT statement, what value does it get?
✗ Incorrect
Columns not specified get NULL or their default value if the table defines one.
Which keyword is used to specify the columns in an INSERT statement?
✗ Incorrect
The INTO keyword is followed by the table name and the list of columns in parentheses.
What happens if you try to insert a row without specifying a NOT NULL column and no default value?
✗ Incorrect
NOT NULL columns without default values must be given a value; otherwise, the insert fails.
Which of these is a valid INSERT statement with specific columns?
✗ Incorrect
Option A is correct syntax. Option B misses INTO. Option C omits columns but may be valid only if all columns are provided. Option D misses a comma between columns.
Explain how to use the INSERT statement to add data to specific columns in a table.
Think about how you tell the database which columns you want to fill.
You got /5 concepts.
What are the consequences of not specifying all columns in an INSERT statement?
Consider what happens to columns you don't mention.
You got /3 concepts.