Consider a table students with columns id (integer) and name (text). Initially, the table is empty.
What will be the output of the following SQL commands?
INSERT INTO students (id, name) VALUES (1, 'Alice'); SELECT * FROM students;
INSERT INTO students (id, name) VALUES (1, 'Alice'); SELECT * FROM students;
Think about what happens when you insert a row and then select all rows.
After inserting one row with id=1 and name='Alice', selecting all rows returns that row.
Which of the following best explains why the INSERT statement is important in databases?
Think about what INSERT does compared to DELETE or SELECT.
INSERT adds new rows (records) to tables, which is essential for storing new information.
Given a table products with columns product_id (integer) and product_name (text), which of the following INSERT statements is correct?
Check the syntax for the INSERT INTO statement carefully.
Option B uses correct syntax: INSERT INTO table VALUES (...);. Option B misses INTO. Option B misses comma between columns. Option B uses VALUE instead of VALUES.
You need to add 1000 new rows to a table orders. Which method is generally more efficient?
Think about how many times the database has to process commands.
One INSERT with many rows reduces overhead and is faster than many single-row INSERTs.
Given a table employees with columns id (integer, primary key) and name (text), what error will this query cause?
INSERT INTO employees (id, name) VALUES (1, 'John'); INSERT INTO employees (id, name) VALUES (1, 'Jane');
Think about what happens if you insert two rows with the same primary key.
The primary key must be unique. Inserting two rows with the same id causes a primary key violation.