Databases Announcements Create Table and Drop Table Create Table - - PowerPoint PPT Presentation

databases announcements create table and drop table
SMART_READER_LITE
LIVE PREVIEW

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-1
SLIDE 1

Databases

slide-2
SLIDE 2

Announcements

slide-3
SLIDE 3

Create Table and Drop Table

slide-4
SLIDE 4

Create Table

4

slide-5
SLIDE 5

CREATE TABLE expression syntax:

Create Table

4

slide-6
SLIDE 6

column-def: CREATE TABLE expression syntax:

Create Table

4

slide-7
SLIDE 7

column-constraint: column-def: CREATE TABLE expression syntax:

Create Table

4

slide-8
SLIDE 8

column-constraint: column-def: CREATE TABLE expression syntax:

Create Table

4

slide-9
SLIDE 9

column-constraint: column-def: CREATE TABLE expression syntax:

Create Table

4

Examples:

slide-10
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
SLIDE 11

Drop Table

5

slide-12
SLIDE 12

Modifying Tables

slide-13
SLIDE 13

Insert

7

slide-14
SLIDE 14

Insert

7

For a table t with two columns...

slide-15
SLIDE 15

Insert

7

To insert into one column: For a table t with two columns...

slide-16
SLIDE 16

Insert

7

To insert into one column: INSERT INTO t(column) VALUES (value); For a table t with two columns...

slide-17
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
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
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
SLIDE 20

Update

8

Update sets all entries in certain columns to new values, just for some subset of rows.

slide-21
SLIDE 21

Update

8

Update sets all entries in certain columns to new values, just for some subset of rows. (Demo)

slide-22
SLIDE 22

Delete

9

Delete removes some or all rows from a table.

slide-23
SLIDE 23

Delete

9

Delete removes some or all rows from a table. (Demo)

slide-24
SLIDE 24

Python and SQL

slide-25
SLIDE 25

Python and SQL

(Demo)

slide-26
SLIDE 26

SQL Injection Attack

slide-27
SLIDE 27

A Program Vulnerable to a SQL Injection Attack

12

https://xkcd.com/327/

slide-28
SLIDE 28

A Program Vulnerable to a SQL Injection Attack

name = "Robert'); DROP TABLE Students; --"

12

https://xkcd.com/327/

slide-29
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
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
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
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
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
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
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
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
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
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
SLIDE 39

Database Connections

slide-40
SLIDE 40

Casino Blackjack

14

Player: Dealer:

slide-41
SLIDE 41

Casino Blackjack

14

Player: Dealer:

slide-42
SLIDE 42

Casino Blackjack

14

Player: Dealer:

slide-43
SLIDE 43

Casino Blackjack

14

Player: Dealer:

slide-44
SLIDE 44

Casino Blackjack

14

Player: Dealer:

slide-45
SLIDE 45

Casino Blackjack

14

Player: Dealer:

slide-46
SLIDE 46

Casino Blackjack

14

Player: Dealer:

slide-47
SLIDE 47

Casino Blackjack

14

Player: Dealer:

slide-48
SLIDE 48

Casino Blackjack

14

Player: Dealer:

slide-49
SLIDE 49

Casino Blackjack

14

Player: Dealer: (Demo)