Search Header Logo

Update Statements

Authored by David Copeland

Computers

12th Grade

Used 1+ times

Update Statements
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

21 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write an UPDATE statement to change the salary of an employee with employee_id 101 to 60000.

UPDATE employees SET salary = 60000 WHERE employee_id = 101;
UPDATE employees SET salary = 60000;
UPDATE employees SET salary = 60000 WHERE employee_id = '101';
UPDATE employees SET salary = 60000 WHERE employee_id = 100;

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you update multiple columns in a single UPDATE statement?

UPDATE table_name SET column1 = value1 SET column2 = value2 WHERE condition;
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
UPDATE table_name SET column1 = value1 AND column2 = value2 WHERE condition;
UPDATE table_name SET column1 = value1, column2 = value2;

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write an UPDATE statement to set the status to 'inactive' for all users who haven't logged in for over a year.

UPDATE users SET status = 'inactive' WHERE last_login < DATE_SUB(NOW(), INTERVAL 1 YEAR);
UPDATE users SET status = 'inactive' WHERE last_login < DATE_SUB(NOW(), INTERVAL 1 MONTH);
UPDATE users SET status = 'inactive' WHERE last_login < DATE_SUB(NOW(), INTERVAL 1 DAY);
UPDATE users SET status = 'inactive' WHERE last_login < DATE_SUB(NOW(), INTERVAL 1 HOUR);

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you update a column based on a calculation involving another column? For example, increasing price by 10%.

UPDATE products SET price = price + 10;
UPDATE products SET price = price * 1.10;
UPDATE products SET price = price / 1.10;
UPDATE products SET price = price - 10;

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write an UPDATE statement to change the department of employees with department_id 5 to 'Sales'.

UPDATE employees SET department = 'Sales' WHERE department_id = 5;
UPDATE employees SET department = 'Sales';
UPDATE employees SET department = 'Sales' WHERE department_id = 6;
UPDATE employees SET department = 'Sales' WHERE department_id = '5';

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why is it important to use the primary key in an UPDATE statement?

It ensures that the UPDATE statement targets a specific, unique row.
It allows updating multiple rows at once.
It improves the readability of the SQL code.
It prevents the need for a WHERE clause.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What could happen if you omit the WHERE clause in an UPDATE statement?

Only the first row will be updated.
All rows in the table will be updated.
No rows will be updated.
An error will be thrown.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?