407 SQL Deep Dive - Amazon Web Services

39
SQL Deep Dive Course Navigation Course Introduction Section 1 Environment Setup Section 2 Introduction to SQL Section 3 Working with Data Section 4 Managing Your Database Section 5 Conclusion Section 6

Transcript of 407 SQL Deep Dive - Amazon Web Services

Page 1: 407 SQL Deep Dive - Amazon Web Services

SQL Deep DiveCourse Navigation

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Page 2: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Course Introduction

Back t o Main

Course Navigation

Getting StartedGet t ing St ar t ed

Get t ing St ar t ed

Dear St udent s. Welcome to the Linux Academy SQL Deep Dive course. I'm excited to have you join me on this adventure!

Data is the new oil, and SQL is your primary tool for working with it. Used across every section of IT, SQL is a powerful and popular tool for storing, manipulating, and reporting on data. No matter what posit ion or level someone is at, mastering the SQL language helps take them further.

In this course we explore all we need to know in order to start working with our data in an effective manner. Prior knowledge about databases will accelerate the learning process, but anyone curious about working with data is welcome.

Thanks for taking the course. Let 's get started!

Landon Fow lerTraining Architect

NextBack

Page 3: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database SetupDat abase Set up

Dat abase Set up

Azure

SQL Server

Database

NextBack

Inst ruct ions

Page 4: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database SetupDat abase Set up

Dat abase Set up

Log in to the Azure Portal.

On the Home page, click SQL dat abases.

Click Creat e sql dat abase.

Set t ing Up t he Azure SQL Dat abase

B

A

C

NextBack

Under Resource group, select a current resource group or create a new one.D

Assign a Database name.E

Page 5: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database SetupDat abase Set up

Dat abase Set up

Under Server , click Creat e new .

Assign a Server name.

Assign an Admin login.

G

F

H

NextBack

Assign a Password, following the requirements.I

Choose a Locat ion near you.J

Check the box to allow Azure services to connect, and click OK.K

Page 6: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database SetupDat abase Set up

Dat abase Set up

Leave Elast ic Pool at No.

Click Conf igure dat abase. Click the area for Basic and then click Apply.

Click Next : Addit ional Set t ings. Under Use exist ing dat a, click Sam ple and then click Review + creat e.

M

L

N

NextBack

Double-check everything and click Creat e.O

Once complete, click Go t o resource, then Set server f irewall at the top. Click Add client IP and add your public IP (it may fill automatically). Click Save.

P

Page 7: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database Setup

Client Set up

Dat abase Set up

Client Set up

Azure Query Edit orThis feature is currently in preview, but will allow us access via the web browser.

SQL Server Managem ent St udio (SSMS)This is the primary tool used for SQL Server administration, but it 's Windows-only.

Visual St udio CodeThis is a cross-platform utility and the one we standardize on for this course.

No matter which option you choose, the syntax rules will be the same across all of them.

Opt ions

B

A

C

NextBack

Inst ruct ions

Page 8: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Environment Setup

Back t o Main

Course Navigation

Client Setup

Database Setup

Client Set up

Dat abase Set up

Client Set up

Download VS Code for your plat formhttps:/ /code.visualstudio.com/

Inst all t he MSSQL ext ensionClick on the Ext ensions icon. Search for MSSQL, and click Inst all .

Connect t o your Azure SQL Dat abase- Open a new document and change the

type by clicking Plain Text at the bottom-right and choosing SQL.

- In the same area, click Disconnect ed.- In the top pane that appears, choose

Creat e Connect ion Prof i le.- Copy/paste the Server Name from your

database overview page and hit Ent er .- Choose SQL Login and hit Ent er .- Enter the Admin login from earlier and hit

Ent er .- Enter the Password from earlier and hit

Ent er . Choose to save and hit Ent er .- Type a Profile Name and hit Ent er .

Visual St udio Code Inst allat ion

B

A

C

NextBack

Page 9: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Introduction to SQL

Back t o Main

Course Navigation

Database BasicsDat abase Basics

Dat abase Basics

What Is an RDBMS?

What Is ANSI SQL (and What Isn't I t )?

Let 's take a moment to clarify a couple of key concepts regarding SQL before proceeding. Laying this groundwork will help us tremendously as we build concepts upon it.

Topics in t h is sect ion include:

B

A

NextBack

Page 10: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Introduction to SQL

Back t o Main

Course Navigation

Database BasicsDat abase Basics

Dat abase Basics

What Is an RDBMS?

A relat ional dat abase follows the relat ional m odel proposed by E. F. Codd in 1970. It 's a collection of data organized into tables, columns, and rows. These tables have well-defined relationships. A Relat ional Dat abase Managem ent Syst em (RDBMS) is software that allows you to interact with and manage relational databases.

Employees

Department

Company

A

OS

AdventureWorks

SQL Server

Close

Page 11: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Introduction to SQL

Back t o Main

Course Navigation

Database BasicsDat abase Basics

Dat abase Basics

What Is ANSI SQL (and What Isn't I t )?

B

Close

St ruct ured Query Language:General concept of a language that accesses and manipulates data.

1

SQL

Am er ican Nat ional St andards Inst it ut e St andard:Standardized SQL rules.

2

ANSI SQL

Manufact urer -specif ic, enhanced versions:PL/SQL, T-SQL, etc.

3

SQL Versions

Page 12: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Basic)

Select :Used to retrieve data from a database.

Where Clauses:Filtering your result set.

Sor t ing Result s:Sorting your result set.

Topics in t h is sect ion include:

B

A

C

NextBack

Null Values:Null is not zero.D

Page 13: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Basic)

SelectA

SELECT * FROM Sal esLT. Cust omer ;

SELECT Fi r st Name, Last Name FROM Sal esLT. Cust omer ;

SELECT col umn1, col umn2FROM t abl e;

Close

Page 14: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Basic)

Where ClausesB

SELECT * FROM Sal esLT. Pr oductWHERE Col or = ' Bl ack' ;

SELECT col umn1, col umn2FROM t abl eWHERE condi t i on;

Close

SELECT * FROM Sal esLT. Pr oductWHERE Col or = ' Bl ack'AND St andar dCost < 1000;

Page 15: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Basic)

Sor t ing Result sC

SELECT Pr oduct I D, Name, St andar dCost FROM Sal esLT. Pr oductWHERE St andar dCost < 100ORDER BY St andar dCost ASC;

SELECT col umn1, col umn2FROM t abl eORDER BY col umn1, col umn2 [ ASC | DESC] ;

Close

SELECT Pr oduct I D, Name, Pr oduct Cat egor yI D, Pr oduct Model I D FROM Sal esLT. Pr oductWHERE St andar dCost < 100ORDER BY Pr oduct Cat egor yI D, Pr oduct Model I D;

Page 16: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Basic)

Null ValuesD

SELECT * FROM Sal esLT. Pr oductWHERE Col or I S NULL;

SELECT col umn1, col umn2FROM t abl eWHERE col umn1 I S [ NOT] NULL;

Close

Page 17: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Select ing Ranges

Fuzzy Lookups

Where Operat ors

Topics in t h is sect ion include:

B

A

C

NextBack

AliasesD

JoinsE

Page 18: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Joins (Advanced)

Logic Condit ions

Topics in t h is sect ion include:

G

F

NextBack

Page 19: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Select ing Ranges

NextBack

A

Top:Retrieve a specific amount.

Min and Max:Return smallest or largest value.

Count , Avg, Sum :Total rows, average value, or sum value.

SELECT TOP number | per cent col umn_name( s)FROM t abl e_name;

SELECT col umn_name( s)FROM t abl e_nameLI MI T number ;

SELECT col umn_name( s)FROM t abl e_nameWHERE ROWNUM <= number ;

T-SQL

MySQL

PL/SQL

SELECT MI N| MAX ( col umn_name) FROM t abl e_name;

SELECT COUNT| AVG| SUM ( col umn_name) FROM t abl e_name;

Topics

Page 20: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Fuzzy Lookups

NextBack

B

Like:Match a pattern.

Wildcards:Substitute one or more characters.

SELECT col umn1FROM t abl e_nameWHERE cl oumn1 LI KE pat t er n;

SELECT col umn1FROM t abl e_nameWHERE cl oumn1 LI KE %pat t er n;

Topics

Page 21: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Where Operat ors

C

In:Specify multiple OR condit ions.

Bet ween:Values included in a specified range.

SELECT col umn1FROM t abl e_nameWHERE cl oumn1 I N ( val ue1, val ue2. . . ) ;

SELECT col umn1FROM t abl e_nameWHERE cl oumn1 BETWEEN val ue1 and val ue2;

NextBack Topics

Page 22: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

AliasesD

Colum n:

Table:

SELECT col umn1 AS al i as_nameFROM t abl e_name;

SELECT col umn1FROM t abl e_name AS al i as_name;

NextBack Topics

Page 23: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

JoinsE

Inner :Rows that have matches from both sides.

Lef t :All from the left, matches from the right.

NextBack Topics

Right :All from the right, matches from the left.

Full Out er :All rows that have a match on either side.

Page 24: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Joins (Advanced)

F

Join

Subquery

NextBack Topics

Union

Page 25: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing Data

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Advanced)

Ret r ieving Dat a (Basic)

Logic Condit ions

NextBack

G

Case

CASE WHEN condi t i on1 THEN r esul t 1 WHEN condi t i on2 THEN r esul t 2 WHEN condi t i on3 THEN r esul t 3 ELSE r esul tEND;

Topics

Page 26: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing DataChanging Dat a

Changing Dat a

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Advanced)

Inser t :Create new rows of data.

Updat e:Change current data.

Delet e:Remove rows of data.

Topics in t h is sect ion include:

B

A

C

NextBack

Page 27: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing DataChanging Dat a

Changing Dat a

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Advanced)

Inser t

NextBack

A

All Colum ns

Specif ic Colum ns

I NSERT I NTO t abl e_nameVALUES ( val ue1, val ue2. . . ) ;

I NSERT I NTO t abl e_name( col umn1, col umn2. . . )VALUES ( val ue1, val ue2. . . ) ;

Topics

Anot her TableSELECT *I NTO newt abl eFROM ol dt abl e;

Page 28: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing DataChanging Dat a

Changing Dat a

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Advanced)

Updat e

NextBack

B

UPDATE t abl e_nameSET col umn1 = val ue1, col umn2 = val ue2, . . .WHERE condi t i on;

Topics

Page 29: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Working with Data

Back t o Main

Course Navigation

Retrieving Data (Advanced)

Retrieving Data (Basic)

Changing DataChanging Dat a

Changing Dat a

Ret r ieving Dat a (Basic)

Ret r ieving Dat a (Advanced)

Delet e

NextBack

C

Topics

DELETE FROM t abl e_nameWHERE condi t i on;

TRUNCATE TABLE t abl e_name;

Delet e

Truncat e

Page 30: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating ObjectsManipulat ing Object s

Manipulat ing Object s

Dat abase

Table

Index

Topics in t h is sect ion include:

B

A

C

NextBack

ViewD

Page 31: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating ObjectsManipulat ing Object s

Manipulat ing Object s

Dat abase

NextBack

A

Creat e

Drop

CREATE DATABASE dbname;

DROP DATABASE dbname;

Topics

Backup BACKUP DATABASE dbnameTO DI SK = ' pat h' ;

Page 32: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating ObjectsManipulat ing Object s

Manipulat ing Object s

Table

NextBack

B

Creat e

Drop

CREATE TABLE t abl e_name (col umn1 dat a_t ype,col umn2 dat a_t ype,. . .) ;

DROP TABLE t abl e_name;

Topics

Alt erALTER TABLE t abl e_nameADD| MODI FY| DROP col umn_name dat a_t ype;

Page 33: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating ObjectsManipulat ing Object s

Manipulat ing Object s

Index

NextBack

C

Creat e

Drop

CREATE I NDEX| UNI QUE I NDEX i ndex_nameON t abl e_name ( col umn1, col umn2) ;

DROP I NDEX i ndex_name ON t abl e_name;

Topics

Page 34: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating ObjectsManipulat ing Object s

Manipulat ing Object s

View

NextBack

D

Creat e

Drop

CREATE VI EW vi ew_name ASSELECT col umn1, col umn2FROM t abl e_nameWHERE condi t i on;

DROP VI EW vi ew_name;

Topics

Alt erALTER VI EW vi ew_name ASSELECT col umn3, col umn4FROM t abl e_nameWHERE ot her _condi t i on;

Page 35: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating Objects

Safeguarding Our Dat abase

Manipulat ing Object s

Safeguarding Our Dat abase

NextBack

SQL Inject ion:What it is, and how to prevent it.

Per form ance:A look from the ground up at getting the most out of a database.

Topics in t h is sect ion include:

B

A

Page 36: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating Objects

Safeguarding Our Dat abase

Manipulat ing Object s

Safeguarding Our Dat abase

SQL Inject ion

NextBack

A

Topics

An attempt to pass SQL queries to our database through unprotected code.

t x t User I d = get Request St r i ng( " User I d" ) ;t xt SQL = " SELECT * FROM User s WHERE User I d = " + t xt User I d;

SELECT * FROM User s WHERE User I d = 105 OR 1=1;

Def in it ion

Exam ple

Page 37: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating Objects

Safeguarding Our Dat abase

Manipulat ing Object s

Safeguarding Our Dat abase

How Can We Prevent I t

NextBack

A.2

Topics

Parameterized queries.

t x t User I d = get Request St r i ng( " User I d" ) ;t xt SQL = " SELECT * FROM User s WHERE User I d = @0" ;db. Execut e( t xt SQL, t xt User I d) ;

Pr im ary St rat egy

Exam ple

Page 38: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Managing Your Database

Back t o Main

Course Navigation

Safeguarding Our Database

Manipulating Objects

Safeguarding Our Dat abase

Manipulat ing Object s

Safeguarding Our Dat abase

Per form ance

NextBack

B

Topics

Hardware

Dat abase

Table

Index

Query

Page 39: 407 SQL Deep Dive - Amazon Web Services

Course Int roduct ionSection 1

Environm ent Set upSection 2

Int roduct ion t o SQLSection 3

Work ing w it h Dat aSection 4

Managing Your Dat abase

Section 5

ConclusionSection 6

Conclusion

Back t o Main

Course Navigation

Final StepsFinal St eps

Final St eps

Dat abase Essent ialsMichael McClaren

Dat abase Adm inist rat ion and SQL Language BasicsMatthew Pearson

What 's Next ?

B

C

Back

Microsof t SQL Server on Linux Quick St ar tLandon FowlerA