UPDATE

Cards (11)

  • UPDATE
    Changing data (rows) in the database
  • UPDATE
    Some uses of UPDATE and the syntax
  • UPDATE table SET (c1 = v1, c2 = v2, ...) WHERE…

    • Which table to change
    • Which columns to change data
    • What's the [optional] condition as to which rows we change?
  • Why WHERE PetID =109 and not WHERE Name = 'Slippery Jim'?

    • PetID is the primary key
    • The primary key is a unique way to reference the specific instance of an entity
    • Primary key will always be unique – name can't be guaranteed!
  • The condition specified in the WHERE clause determines how many rows will be updated
  • Without the WHERE clause will update all records!
  • UPDATE Warning! No WHERE clause means all rows match. Be careful - If you omit the WHERE clause, ALL records will be updated!
  • Both are acceptable, but best to stick to method (b) for consistency
  • We put quotes around textual values
  • Numerical values can be quoted or not
  • Escaping Quotes: Use the escape character (like with Java): \