0% found this document useful (0 votes)
3 views

WEEK 10 DBAS6211 Stored Procedure

The document discusses the concepts of stored procedures and temporary tables in relational databases. It outlines the benefits and drawbacks of stored procedures, including reduced database traffic and improved security, while also noting challenges in debugging and maintenance. Additionally, it explains temporary tables, their types, and their usage in queries, highlighting the trade-off between speed and memory usage.

Uploaded by

Fathima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

WEEK 10 DBAS6211 Stored Procedure

The document discusses the concepts of stored procedures and temporary tables in relational databases. It outlines the benefits and drawbacks of stored procedures, including reduced database traffic and improved security, while also noting challenges in debugging and maintenance. Additionally, it explains temporary tables, their types, and their usage in queries, highlighting the trade-off between speed and memory usage.

Uploaded by

Fathima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

IIE ROSEBANK COLLEGE

TOPIC 5: MAY 2023

Rosebank College is an educational brand of The Independent Institute of Education (Pty) Ltd which is registered with the Department of Higher
Education and Training as a private higher education institution under the Higher Education Act, 1997 (reg. no. 2007/HE07/002). Company
registration number: 1987/004754/07.
CONTENT: LEARNING UNIT 3:CREATING A
RELATIONAL DATABASE
Theme 3: Stored Procedures
LO5: Explain the purpose of a stored procedure.
LO6: Create a stored procedure using SQL.
Theme 4: Temporary Tables
LO7: Explain the purpose of a temporary table.
LO8: Identify the types of temporary tables.
LO9: Use temporary tables in queries.
What is a Stored Procedure
• If we have a SELECT query that we use a lot, we can use a view to give
that query a name. And that means we can easily call it as we have
already seen above. But what if we have other SQL statements that
get called very often? How can we make those reusable? By creating a
stored procedure. (Soderberg, 2019)
BENEFITS AND DRAWBACKS
• There are several benefits to using stored procedures (mysqltutorial.org, 2020b):
• There is less traffic between applications and the database, because now one call
to a stored procedure replaces multiple other calls to the database;
• The business logic is contained in one central place: in the database itself; and
• Security can be better since an application would only need access to the stored
procedures that it uses.
• However, there are also drawbacks to this approach (mysqltutorial.org, 2020b):
• Lots of stored procedures means that each database connection uses lots of
memory;
• Issues in a stored procedure are very hard to debug; and • Maintaining stored
procedures requires special skills that not everybody has.
Creating a Stored Procedure
What is a Temporary Table?
• A temporary table is a table that is, well, temporary. It is used to store
data for a short period, after which it is deleted again. Temporary
tables will automatically get dropped when the user disconnects.
(JavaTpoint, n.d.)
• Unlike normal views, in a temporary table the values do get stored
Types of Temporary Tables
• There are two ways in which temporary tables can be stored: in
memory or on disk. (Olamendy, 2017) In-memory temporary tables
are faster for small data sets but use memory which is far more
limited than disk space. So, it is a trade-off between speed and
memory usage.
• Using a temporary table that is stored on disk is still fast, especially
since these tables do support indexing. So, for larger data sets using a
temporary stored on disk works well.
Using Temporary Tables
Temporary Table from Query
Data in the Temporary Table

You might also like