Skip to content

Database Modification

Deletion

  • DELETE from <table> - deletes everything in the table
  • DELETE FROM <table> WHERE <condition> - deletes rows conditionally from the table

Insertion

  • INSERT into <table> values (tuple) - inserts a row into the table
  • null may be inserted in any cell as well
  • INSERT into <table>(tuple) values (tuple) - inserts into some rows only
  • you can also insert the result of one query into another table

Update

  • UPDATE <table> SET <attribute> = <value>
  • UPDATE instructor SET salary = 1.05 * salary is a valid query

Case

  • case is used to implement an if else
    UPDATE instructor
        SET salary = CASE
            WHEN salary <= 100000 THEN salary * 1.05
                                  ELSE salary * 1.03
            END