0% found this document useful (0 votes)
5 views7 pages

SQL Class 4 PPT

The document outlines key SQL concepts including Views, Stored Procedures, and Indexes. Views are virtual tables created from SQL statements, while Stored Procedures are reusable SQL code that can accept parameters. Indexes improve query performance by providing quick references to data, with various types such as Single-Column, Composite, and Unique Indexes detailed.

Uploaded by

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

SQL Class 4 PPT

The document outlines key SQL concepts including Views, Stored Procedures, and Indexes. Views are virtual tables created from SQL statements, while Stored Procedures are reusable SQL code that can accept parameters. Indexes improve query performance by providing quick references to data, with various types such as Single-Column, Composite, and Unique Indexes detailed.

Uploaded by

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

AGENDA

WINDOW FUNCTIONS

COMMON TABLE EXPRESSIONS(CTE)

VIEWS

STORED PROCEDURES

INDEXES
VIEWS IN SQL

• View is a virtual table based on the result-set of an SQL statement.

• A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

• You can add SQL statements and functions to a view and present the data as if the data were coming from one single table.

• A view is created with the CREATE VIEW statement.


STORED PROCEDURES IN SQL

• A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.

• So if you have an SQL query that you write over and over again, save it as a stored procedure, and then just call it to execute it.

• You can also pass parameters to a stored procedure, so that the stored procedure can act based on the parameter value(s) that is
passed.
INDEXES IN SQL

• Indexes are references to data which are used by queries to find data from tables quickly.
• It cannot be viewed by the users and just used to speed up the database access.
• Without index, the query engine checks every row in the table from beginning till the end- TABLE SCAN

To reference all pages in a book that address a


particular subject, you go to the index first,
which lists all the topics alphabetically, and then
you go to one or more specific page numbers.
INDEXES IN SQL
INDEXES IN SQL
TYPES OF INDEXES

1. Single-Column
Index:
-- Create a single-column index on customer_id
CREATE INDEX idx_customer_id ON customer_orders(customer_id);

2. Composite Index:

-- Create a composite index on customer_id and order_date


CREATE INDEX idx_customer_order_date ON customer_orders(customer_id, order_date);

3. Unique Index:

-- Create a unique index on order_id


CREATE UNIQUE INDEX idx_unique_order_id ON customer_orders(order_id);

You might also like