W3. SQL Update Flashcards

1
Q

Q: What is the purpose of the SQL UPDATE statement?

A

A: To modify existing records in a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: What is the syntax for the UPDATE statement?

A
UPDATE table_name 
SET column1 = value1, column2 = value2, ... 
WHERE condition;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: Why is the WHERE clause important in an UPDATE statement?

A

A: It specifies which records to update; omitting it updates all records in the table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: Write an example query to update the contact name and city for the customer with CustomerID = 1.

A
UPDATE Customers 
SET ContactName = 'Alfred Schmidt', City = 'Frankfurt' 
WHERE CustomerID = 1;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: How does the WHERE clause affect the number of records updated?

A

A: It limits the update to records that meet the specified condition(s).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: Write a query to set the ContactName to “Juan” for all records where the country is “Mexico.”

A
UPDATE Customers 
SET ContactName = 'Juan' 
WHERE Country = 'Mexico';
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: What happens if you omit the WHERE clause in an UPDATE statement?

A

A: All records in the table will be updated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: Provide an example of an UPDATE statement without a WHERE clause.

A
UPDATE Customers 
SET ContactName = 'Juan';

(This will update the ContactName for all records in the table.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly