SLIDE 1
Databases Announcements Create Table and Drop Table Create Table - - PowerPoint PPT Presentation
Databases Announcements Create Table and Drop Table Create Table - - PowerPoint PPT Presentation
Databases Announcements Create Table and Drop Table Create Table 4 Create Table CREATE TABLE expression syntax: 4 Create Table CREATE TABLE expression syntax: column-def: 4 Create Table CREATE TABLE expression syntax:
SLIDE 2
SLIDE 3
Create Table and Drop Table
SLIDE 4
Create Table
4
SLIDE 5
CREATE TABLE expression syntax:
Create Table
4
SLIDE 6
column-def: CREATE TABLE expression syntax:
Create Table
4
SLIDE 7
column-constraint: column-def: CREATE TABLE expression syntax:
Create Table
4
SLIDE 8
column-constraint: column-def: CREATE TABLE expression syntax:
Create Table
4
SLIDE 9
column-constraint: column-def: CREATE TABLE expression syntax:
Create Table
4
Examples:
SLIDE 10
column-constraint: column-def: CREATE TABLE expression syntax:
Create Table
4
Examples:
CREATE TABLE numbers (n, note); CREATE TABLE numbers (n UNIQUE, note); CREATE TABLE numbers (n, note DEFAULT "No comment");
SLIDE 11
Drop Table
5
SLIDE 12
Modifying Tables
SLIDE 13
Insert
7
SLIDE 14
Insert
7
For a table t with two columns...
SLIDE 15
Insert
7
To insert into one column: For a table t with two columns...
SLIDE 16
Insert
7
To insert into one column: INSERT INTO t(column) VALUES (value); For a table t with two columns...
SLIDE 17
Insert
7
To insert into one column: INSERT INTO t(column) VALUES (value); To insert into both columns: For a table t with two columns...
SLIDE 18
Insert
7
To insert into one column: INSERT INTO t(column) VALUES (value); To insert into both columns: For a table t with two columns... INSERT INTO t VALUES (value0, value1);
SLIDE 19
Insert
7
(Demo) To insert into one column: INSERT INTO t(column) VALUES (value); To insert into both columns: For a table t with two columns... INSERT INTO t VALUES (value0, value1);
SLIDE 20
Update
8
Update sets all entries in certain columns to new values, just for some subset of rows.
SLIDE 21
Update
8
Update sets all entries in certain columns to new values, just for some subset of rows. (Demo)
SLIDE 22
Delete
9
Delete removes some or all rows from a table.
SLIDE 23
Delete
9
Delete removes some or all rows from a table. (Demo)
SLIDE 24
Python and SQL
SLIDE 25
Python and SQL
(Demo)
SLIDE 26
SQL Injection Attack
SLIDE 27
A Program Vulnerable to a SQL Injection Attack
12
https://xkcd.com/327/
SLIDE 28
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --"
12
https://xkcd.com/327/
SLIDE 29
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');"
12
https://xkcd.com/327/
SLIDE 30
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
https://xkcd.com/327/
SLIDE 31
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 32
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 33
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 34
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 35
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 36
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); db.execute("INSERT INTO Students VALUES (?)", [name]) https://xkcd.com/327/
SLIDE 37
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); db.execute("INSERT INTO Students VALUES (?)", [name]) INSERT INTO Students VALUES ('Robert''); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 38
A Program Vulnerable to a SQL Injection Attack
name = "Robert'); DROP TABLE Students; --" cmd = "INSERT INTO Students VALUES ('" + name + "');" db.executescript(cmd)
12
INSERT INTO Students VALUES ('Robert'); DROP TABLE Students; --'); https://xkcd.com/327/ db.execute("INSERT INTO Students VALUES (?)", [name]) INSERT INTO Students VALUES ('Robert''); DROP TABLE Students; --'); https://xkcd.com/327/
SLIDE 39
Database Connections
SLIDE 40
Casino Blackjack
14
Player: Dealer:
SLIDE 41
Casino Blackjack
14
Player: Dealer:
SLIDE 42
Casino Blackjack
14
Player: Dealer:
SLIDE 43
Casino Blackjack
14
Player: Dealer:
SLIDE 44
Casino Blackjack
14
Player: Dealer:
SLIDE 45
Casino Blackjack
14
Player: Dealer:
SLIDE 46
Casino Blackjack
14
Player: Dealer:
SLIDE 47
Casino Blackjack
14
Player: Dealer:
SLIDE 48
Casino Blackjack
14
Player: Dealer:
SLIDE 49
Casino Blackjack
14