0
0
MySQLquery~5 mins

INSERT INTO single row in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL command INSERT INTO do?
It adds a new row of data into a table in the database.
Click to reveal answer
beginner
Write the basic syntax to insert a single row into a table named users with columns name and age.
INSERT INTO users (name, age) VALUES ('Alice', 30);
Click to reveal answer
intermediate
Can you insert a row without specifying column names? When is it allowed?
Yes, if you provide values for all columns in the exact order they appear in the table. Otherwise, you must specify column names.
Click to reveal answer
intermediate
What happens if you try to insert a row with a missing value for a column that does not allow NULL?
The database will return an error because that column requires a value and cannot be empty.
Click to reveal answer
beginner
Why is it a good idea to specify column names in an INSERT INTO statement?
It makes your query clearer and safer, especially if the table structure changes later. It also avoids mistakes with column order.
Click to reveal answer
Which SQL keyword is used to add a single row to a table?
AUPDATE
BSELECT
CINSERT INTO
DDELETE
What must you include in an INSERT INTO statement to add data correctly?
ATable name and values
BOnly values
COnly table name
DColumn names and values
What happens if you omit column names but provide fewer values than columns in the table?
AAn error occurs
BThe database guesses the columns
CThe row is inserted with NULLs
DThe row is inserted with default values
Which of these is a correct INSERT INTO statement for table products(id, name)?
AINSERT INTO products (id, name) VALUES (1, 'Pen');
BINSERT INTO products VALUES (1, 'Pen');
CINSERT products (id, name) VALUES (1, 'Pen');
DINSERT INTO products (name, id) VALUES ('Pen', 1);
Why might you get an error inserting a row with a missing value?
ABecause the value is too large
BBecause the column is set to NOT NULL
CBecause the database is offline
DBecause the table is empty
Explain how to insert a single row into a MySQL table and why specifying column names is important.
Think about matching data to the right place in the table.
You got /4 concepts.
    What errors might occur when inserting a single row and how can you prevent them?
    Consider the rules the database enforces on data.
    You got /4 concepts.