DML, Constraints, Assertions, Triggers




CS157a

Chris Pollett

Nov 28, 2018

Outline

Introduction

Database Modifications

INSERTs with a Query

Deletion

  • The SQL syntax to delete some rows from a database is:
       DELETE FROM R WHERE <condition>;
    
  • The WHERE clause above is allowed to have anything that a SELECT FROM WHERE clause can have (including subqueries).
  • For example, suppose we want to delete all movies from before 1970 whose title contains the word 'Star'. We could do this with:
    DELETE FROM Movies
    WHERE title LIKE '%Star%'
      AND year < 1970;
    
  • Updates

    In-Class Exercise

    SQL Data Definition Commands

    Specifying Integrity Constraints in SQL

    Data Modification and Integrity Constraints

    CHECK Constraints

    Naming Constraints and Altering Them

    Active Databases

    Assertions

    Triggers