Web Programming Step by Step

Lecture XX
More SQL Syntax

Except where otherwise noted, the contents of this presentation are Copyright 2010 Marty Stepp and Jessica Miller.

Valid XHTML 1.1 Valid CSS!

Entities and relationships

ER diagram

The SQL INSERT statement

INSERT INTO table

VALUES (value, value, ..., value);
INSERT INTO Student 
VALUES (789, "Nelson", "muntz@fox.com");

The SQL UPDATE statement

UPDATE table
SET column = value,
    ...,
    column = value
WHERE column = value;

UPDATE Student
SET    email = "lisasimpson@gmail.com"
WHERE  SID = 888;

The SQL CREATE TABLE statement

CREATE TABLE name (
    columnName type constraints,
    ...
    columnName type constraints

);
CREATE TABLE Student (
    SID INTEGER UNSIGNED NOT NULL PRIMARY KEY,
    name VARCHAR(20),
    email VARCHAR(32)
);

SQL data types