Q1
True / FalseThe MySQL "INSERT" statement can be used to add new rows to a table.
The primary purpose of the "INSERT" statement in MySQL is to add new rows to a table.
Q2
True / FalseIn MySQL, the "INSERT" statement can insert multiple rows into a table with a single command.
MySQL allows inserting multiple rows in a single "INSERT" statement by separating the values for each row with a comma.
Q3
True / FalseThe "INSERT" statement in MySQL requires all column names to be specified.
It is not mandatory to specify all column names in an "INSERT" statement if the table has default values for the columns or allows NULL values.
Q4
True / FalseThe MySQL "INSERT IGNORE" statement inserts a new row but ignores errors for duplicate key violations.
"INSERT IGNORE" in MySQL inserts a new row while ignoring duplicate key violations and other errors that would normally cause the statement to fail.
Q5
True / FalseThe "INSERT INTO ... SELECT" statement in MySQL can copy data from one table to another.
The "INSERT INTO ... SELECT" statement allows copying data from one table and inserting it into another table in MySQL.
Q6
True / FalseIn MySQL, you cannot use subqueries within an "INSERT" statement.
MySQL supports using subqueries within an "INSERT" statement to determine the data to be inserted.
Q7
True / FalseThe "INSERT ON DUPLICATE KEY UPDATE" statement in MySQL updates existing rows when a duplicate key is found.
"INSERT ON DUPLICATE KEY UPDATE" in MySQL inserts a row if the key does not exist, or updates the row if the key already exists.
Q8
True / FalseMySQL allows inserting data into a view using an "INSERT" statement.
MySQL allows inserting data into a view, provided the view is updatable and the insert operation complies with the view's constraints.
Q9
True / FalseThe "INSERT" statement in MySQL can be used with stored procedures.
MySQL allows "INSERT" statements to be used within stored procedures to add rows to a table.
Q10
True / FalseThe MySQL "INSERT DELAYED" statement improves performance by delaying the insert operation until the table is free.
As of MySQL 5.6.6, the "INSERT DELAYED" statement is deprecated and does not improve performance as it once did. The statement was removed in MySQL 8.0.
Q15
Single ChoiceHow can you insert multiple rows into a MySQL table with a single INSERT statement?
In MySQL, you can insert multiple rows into a table by specifying each set of values in the VALUES clause separated by commas.
Q21
Multiple ChoiceIdentify the correct SQL statement to insert a new row into a table with all columns specified.
SQL Code
INSERT INTO employees (employee_id, first_name, last_name, department)
VALUES (1, 'John', 'Doe', 'HR');
The INSERT INTO statement is used to insert a new row into the employees table. All columns are explicitly listed and provided with corresponding values.
Q22
Multiple ChoiceChoose the correct SQL statement to insert a new row with only specific columns specified.
SQL Code
INSERT INTO products (product_name, price)
VALUES ('Laptop', 1500);
This SQL statement inserts a new row into the products table, only specifying the product_name and price columns, while other columns will take default or NULL values.
Q23
Multiple ChoiceDetermine the correct SQL statement to insert multiple rows into a table in a single query.
SQL Code
INSERT INTO orders (order_id, customer_id, order_date)
VALUES (1, 101, '2024-01-01'),
(2, 102, '2024-01-02');
This SQL statement inserts multiple rows into the orders table in a single query, each set of values is enclosed in parentheses and separated by commas.
Q24
Multiple ChoiceWhich SQL statement correctly uses INSERT IGNORE to avoid inserting a row if a duplicate key exists?
SQL Code
INSERT IGNORE INTO users (user_id, username, email)
VALUES (1, 'jdoe', 'jdoe@example.com');
The INSERT IGNORE statement is used to insert a row, but if a duplicate key conflict occurs (e.g., the user_id already exists), the insert is ignored without an error.
Q25
Multiple ChoiceSelect the correct SQL statement to insert data into a table using a SELECT statement.
SQL Code
INSERT INTO archive_orders (order_id, customer_id, order_date)
SELECT order_id, customer_id, order_date
FROM orders
WHERE order_date < '2023-01-01';
The INSERT INTO...SELECT statement is used to insert data from one table into another table based on a query.
Q26
Multiple ChoiceDetermine the correct SQL statement to insert a row and return the AUTO_INCREMENT value of the inserted row.
SQL Code
INSERT INTO transactions (amount, transaction_date)
VALUES (100, '2024-01-01');
SELECT LAST_INSERT_ID();
The LAST_INSERT_ID() function is used to retrieve the AUTO_INCREMENT value generated by the most recent INSERT operation.
Q27
Multiple ChoiceWhich SQL statement correctly inserts data into a table with a BLOB column?
SQL Code
INSERT INTO images (image_id, image_data)
VALUES (1, LOAD_FILE('/path/to/image.jpg'));
The LOAD_FILE function is used to read the contents of a file and insert it into a BLOB column.
Q28
Multiple ChoiceSelect the correct SQL statement to insert data into a table with a TIMESTAMP column that uses the current time as a default.
SQL Code
INSERT INTO log_entries (log_id, log_message)
VALUES (NULL, 'System rebooted');
When the TIMESTAMP column has a default value of CURRENT_TIMESTAMP, inserting NULL or omitting the column will insert the current time.
Q30
Multiple ChoiceIdentify the correct SQL statement to insert data into a table with a generated column.
SQL Code
INSERT INTO orders (product_id, quantity)
VALUES (101, 2);
When inserting data into a table with a generated column, the values for the generated column are calculated automatically based on the expression defined during table creation.