0
0
SQLquery~5 mins

INSERT INTO single row in SQL - 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 students with columns id and name.
INSERT INTO students (id, name) VALUES (1, 'Alice');
Click to reveal answer
intermediate
Can you insert a row without specifying column names in SQL?
Yes, if you provide values for all columns in the exact order they appear in the table.
Click to reveal answer
intermediate
What happens if you try to insert a row with a duplicate primary key?
The database will reject the insert and return an error because primary keys must be unique.
Click to reveal answer
beginner
Why is it a good practice to specify column names in an INSERT INTO statement?
It makes the query clearer and safer, especially if the table structure changes later.
Click to reveal answer
Which SQL keyword is used to add a new row to a table?
AINSERT INTO
BSELECT
CUPDATE
DDELETE
What must you include in an INSERT INTO statement to add a single row?
ATable name and SELECT statement
BOnly table name
CTable name and values
DOnly values
If a table has columns id, name, and age, which is a correct insert statement?
AINSERT INTO table VALUES ('Bob', 25, 1);
BINSERT INTO table (id, name, age) VALUES (1, 'Bob', 25);
CINSERT table (id, name, age) VALUES (1, 'Bob', 25);
DINSERT INTO table (id, name) VALUES (1, 'Bob', 25);
What error occurs if you insert a row with a duplicate primary key?
ANo error, row is added
BSyntax error
CData type mismatch
DUnique constraint violation
Is it mandatory to specify column names in an INSERT INTO statement?
ANo, if you provide values for all columns in order
BYes, always mandatory
COnly for tables with one column
DOnly for tables with primary keys
Explain how to insert a single row into a SQL table and why specifying column names is helpful.
Think about the syntax and benefits of naming columns.
You got /3 concepts.
    What happens if you try to insert a row with a duplicate primary key? How can you avoid this?
    Consider the role of primary keys in uniqueness.
    You got /4 concepts.