![]() ![]() The UPDATE clause identifies airplanes as the target table, and the SET clause specifies that the values in the wingspan column should be rounded, which is achieved by using the built-in ROUND function. To achieve this, you create the following UPDATE statement: Suppose you want to round all the values in the wingspan column in the airplanes table to whole numbers. As I already mentioned, the UPDATE and SET clauses are the only required clauses, so let’s start with them. Now that you have a basic overview of the UPDATE statement syntax, it’s time to see the statement in action so you can get a feel for how it works. When you do update the production environment, be sure to do it within a transaction, a topic I plan to cover later in the series. Certainly, don’t practice in a production environment. Data modifications can be difficult to undo, so you need to proceed cautiously, especially when you’re first learning how to use the UPDATE statement. In fact, it’s almost too easy to update data, and if you’re not careful, you could make a significant mess of things. Once you see the statement in action, you should have no problem understanding how all the clauses work and using them to update data. Most of the time, you’ll be using the UPDATE, SET and WHERE clauses, although the ORDER BY clause and LIMIT clause can also come in handy at times. With these five clauses, you can build a wide range of UPDATE statements. As with the ORDER BY clause, the LIMIT clause cannot be used for multi-table updates. This means that the statement will stop based on the number of rows that satisfy the WHERE conditions, whether or not those rows are actually updated. If you include a WHERE clause, the count applies to the rows returned by that clause. The LIMIT clause limits the number of rows that will be updated.The clause cannot be used for multi-table updates. ![]() The ORDER BY clause is similar to the one you saw in the SELECT statement. This can be useful in situations that might otherwise result in an error, as you’ll see later in the article.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |