0% found this document useful (0 votes)
115 views2 pages

Assignment 8

Indexes and views are discussed, with indexes being ordered lists of columns that can be simple (single column) or composite (multiple columns) and views providing a logical representation of data through selection and projection. Creation of indexes and views is demonstrated through SQL syntax, along with dropping indexes and views, with an example assignment provided to implement indexes on tables and create and query views.

Uploaded by

aditya b
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)
115 views2 pages

Assignment 8

Indexes and views are discussed, with indexes being ordered lists of columns that can be simple (single column) or composite (multiple columns) and views providing a logical representation of data through selection and projection. Creation of indexes and views is demonstrated through SQL syntax, along with dropping indexes and views, with an example assignment provided to implement indexes on tables and create and query views.

Uploaded by

aditya b
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/ 2

Theory and Concept

Practical # 8

Objective:- To implement the concept of Indexes and views.


Indexes- An index is an ordered list of content of a column or group of columns in a table.
An index created on the single column of the table is called simple index. When multiple
table columns are included in the index it is called composite index.
Creating an Index for a table:-
Syntax (Simple)
CREATE INDEX index_name
ON tablename(column name);
Composite Index:-
CREATE INDEX index_name
ON tablename(columnname,columnname);
Creating an UniQuestion Index:-
CREATE UNIQUESTION INDEX indexfilename
ON tablename(columnname);
Dropping Indexes:-
An index can be dropped by using DROP INDEX
SYNTAX:-
DROP INDEX indexfilename;
Views:-
Logical data is how we want to see the current data in our database. Physical data
is how this data is actually placed in our database.
Views are masks placed upon tables. This allows the programmer to develop a
method via which we can display predetermined data to users according to our desire.
Views may be created fore the following reasons:

1. The DBA stores the views as a definition only. Hence there is no duplication of data.
2. Simplifies Queries.
3. Can be Queried as a base table itself.
4. Provides data security.
5. Avoids data redundancy.

Creation of Views:-
Syntax:-
CREATE VIEW viewname AS
SELECT columnname,columnname
FROM tablename
WHERE columnname=expression_list;
Renaming the columns of a view:-

Syntax:-
CREATE VIEW viewname AS
SELECT newcolumnname….
FROM tablename
WHERE columnname=expression_list;

Selecting a data set from a view-

Syntax:-
SELECT columnname, columnname
FROM viewname
WHERE search condition;

Destroying a view-

Syntax:-
DROP VIEW viewname;

Assignment No # 8

Objective : Answer the following Questions

Q1. Create an index on the table client_master, field client_no.


Q2. Create an index on the sales_order, field s_order_no.
Q3. Create an composite index on the sales_order_details table for the columns
s_order_no and product_no.
Q4. Create an composite index ch_index on challan_header table for the columns
challan no and s_order_no.
Q5. Create an uniQuestion index on the table salesman_master, field salesman_no.
Q6. Drop index ch_index on table challan_header.
Q7. Create view on salesman_master whose sal_amt is less than 3500.
Q8. Create a view client_view on client_master and rename the columns as name,
add1, add2, city, pcode, state respectively.
Q9. Select the client names from client_view who lives in city ‘Bombay’.
Q10. Drop the view client_view.

You might also like