more advanced pl/sql programing

9
Advanced Databases More Advanced PL/SQL Programing 1

Upload: evan-mills

Post on 02-Jan-2016

32 views

Category:

Documents


1 download

DESCRIPTION

More Advanced PL/SQL Programing. Agenda. Indexes Not PL/SQL but a RBMS performance enhancement PL/SQL Functions Cursor For Loops. Indexes. Table. Table Index on Color. Impacts on: SELECT? INSERT? UPDATE? DELETE?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: More  Advanced  PL/SQL Programing

Advanced Databases 1

More Advanced PL/SQL Programing

Page 2: More  Advanced  PL/SQL Programing

Advanced Databases 2

Agenda

• Indexes – Not PL/SQL but a RBMS performance

enhancement

• PL/SQL– Functions– Cursor For Loops

Page 3: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

3

Indexes

• Database object which provides capability to speed up the search process.

ID Color

1 Red2 Blue

3 Red

4 Red

5 Blue

6 Green

7 Red

8 Red

Color ID’s

Blue 2, 5Green 6

Red 1, 3, 4, 7, 8

Table Table Index on Color

Impacts on:SELECT? INSERT? UPDATE? DELETE?

Page 4: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

4

Indexes in SQL

Page 5: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

5

Why not Index Everything?

• Every Index makes one of those “index tables”

• If you have 10 indexes on a table, an INSERT, DELETE or UPDATE needs to write to that table + the 10 index tables.

• Indexing speeds up reads at the expense of writes.

Page 6: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

6

Functions

• Functions are stored procedures which return a value.

• Functions are not executed like stored procedures. Instead, they are called from within SQL or PL/SQL.

• SELECT myfunction() …

Page 7: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

7

Functions

Page 8: More  Advanced  PL/SQL Programing

Advanced Databases

Guide to Oracle 10g

8

Cursor For Loops

• Easier to implement cursors. • Simplified – no open, close, fetch or exit

conditions!• If you need to use a cursor, use these.

Page 9: More  Advanced  PL/SQL Programing

Advanced Databases 9

Questions