Modifying Stored Data - Page 5
January 10, 2002
Once you've entered your data into a database table, you might
like to change it at some point. Whether you want to correct a
spelling mistake, or change the date attached to a joke, such
alterations are made using the
So, for example, if we wanted to change the date on the joke we entered above, we'd use the following command:
Here's where that ID column comes in handy. It allows us to
easily single out a joke for changes. The
Deleting Stored Data
The deletion of entries in SQL is dangerously easy (if you can't tell by now, this is a recurring theme). Here's the command syntax:
So to delete all chicken jokes from your table, you'd use the following query:
One thing to note is that the
There's a lot more to the MySQL database system and the SQL language than the few basic commands we've looked at here, but these commands are by far the most commonly used. So far we've only worked with a single table. To realize the true power of a relational database, we'll also need to learn how to use multiple tables together to represent potentially complex relationships between database entities.
All this and more will be covered in Chapter 5, where we'll discuss database design principles, and look at some more advanced examples. For now, though, we've hopefully accomplished our objective, and you can comfortably interact with MySQL using the command line interface.