Updating Data

11 important questions on Updating Data

What are the 2 syntaxes for a INSERT statement?

INSERT INTO table_name  (column_list) VALUES (value_list);

INSERT INTO table_name
    SET column_name = value  [, column_name = value] ... ;

What are the 2 differences between INSERT SET and INSERT VALUES()?

with INSERT VALUES you can omit columns and values

When inserting multiple rows with INSERT VALUES(), does each set need it's own ()?

Yes
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

What is the benefit of ON DUPLICATE KEY UPDATE above two separate statements?

It's saves you from explicitly having to lock the table in between insert and update

Does the update of an ON DUPLICATE KEY UPDATE clause count as separate affected row?

Yes

What is the benefit of using REPLACE above a separate DELETE and INSERT statement?

It does not require you to explicitly have to lock the table in between DELETE and INSERT. It is a single atomic operation

Do multiple NULL values count as duplicate key for a REPLACE statement?

No

What is the syntax of an UPDATE statement?

UPDATE table_name
    SET column_name> = value [, column_name = value] ...
    WHERE .... ;

Do records that match the WHERE clause of an update statement always count as affected_rows?

No, only if data changes

What is the syntax of a DELETE statement?

DELETE FROM table_name;
TRUNCATE TABLE table_name;

Does TRUNCATE (TABLE) return a true row count of the deleted set?

No

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo