0
0
SQLquery~5 mins

INSERT with specific columns in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AINSERT INTO people (name) VALUES ('John', 30);
BINSERT INTO people VALUES ('John', 30);
CINSERT people (name, age) VALUES ('John', 30);
DINSERT INTO people (name, age) VALUES ('John', 30);
If a column is not listed in the INSERT statement, what value does it get?
ARandom value
BThe last inserted value
CNULL or default value if defined
DIt causes the database to crash
Which keyword is used to specify the columns in an INSERT statement?
AINTO
BVALUES
CSELECT
DNone, columns are not specified
What happens if you try to insert a row without specifying a NOT NULL column and no default value?
AThe database ignores the column
BThe insert fails with an error
CThe database inserts a zero
DThe column is set to NULL
Which of these is a valid INSERT statement with specific columns?
AINSERT INTO orders (order_id, customer) VALUES (101, 'Bob');
BINSERT orders (order_id, customer) VALUES (101, 'Bob');
CINSERT INTO orders VALUES (101, 'Bob');
DINSERT INTO orders (order_id customer) VALUES (101, 'Bob');
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.