17. Modifying Data

Keywords Introduced

INSERT INTO  •  VALUES  •  DELETE  •  TRUNCATE TABLE  •  UPDATE  •  SET

Having exhausted our discussion of retrieving data from databases, we now move on to the question of how to modify data in a database. There are three basic scenarios as to how data can be modified:

• Inserting new rows into a table

• Deleting rows from a table

• Updating existing data in specific rows and columns in a table

As may be surmised, inserting and deleting rows is relatively straightforward. Updating existing data, however, is a more complex endeavor, as it involves identifying the rows to be updated and also the specific columns in those rows. We’ll begin with the inserts and deletes and then move on to updates.

Modification ...

Get The Language of SQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.