0% found this document useful (0 votes)
16 views6 pages

Dbms Ex8

The document outlines an exercise aimed at creating queries using database objects such as Views, Sequences, Indexes, and Synonyms. It includes definitions, syntax, and practical questions to implement these concepts in a Database Management Systems Lab. The exercise concludes with a successful creation of the specified database objects.

Uploaded by

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

Dbms Ex8

The document outlines an exercise aimed at creating queries using database objects such as Views, Sequences, Indexes, and Synonyms. It includes definitions, syntax, and practical questions to implement these concepts in a Database Management Systems Lab. The exercise concludes with a successful creation of the specified database objects.

Uploaded by

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

20CS2016L - Database Management

Systems Lab URK22CS3013

Ex. No. 8 OTHER DATABASE OBJECTS(VIEWS, SEQUENCES, INDEX & SYNONYMS)

Date of Exercise 18-10-2024


Aim:
To create queries for given questions using Views, Sequences, Index and Synonyms

Description:
Views: A View is a virtual table created by a SQL query that combines data from one or more tables. It
does not store data itself but provides a way to simplify complex queries by encapsulating them into a
single object. Views help in abstracting the complexity and can also be used to limit data access to
certain users.
Syntax:
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Sequences A sequence is a database object that generates a sequence of unique numbers, typically used
for automatically generating primary key values. Sequences are independent of tables and are useful for
auto-incrementing fields such as user IDs or invoice numbers. Once created, they can be referenced to
get the next value or the current value.
Syntax:
CREATE SEQUENCE sequence_name
START WITH start_value
INCREMENT BY increment_value;
Indexes
An index is a database object that improves the speed of data retrieval on a table by providing a faster
lookup method for specific columns. While it speeds up searches, it can also slow down insert, update,
or delete operations because the index must be maintained. Indexes are commonly created on columns
that are frequently used in WHERE clauses or joins.
Syntax:
CREATE INDEX index_name
ON table_name (column_name);
Synonyms
A synonym is an alias for another database object such as a table, view, or sequence. It simplifies access
to objects, especially when referencing objects in remote databases or with complex names. Synonyms
can make queries more readable and allow changes to underlying object names without impacting
dependent applications.
Syntax:
CREATE SYNONYM synonym_name
FOR object_name;
20CS2016L - Database Management
Systems Lab URK22CS3013

Questions:
1. Design a view that present a list of venues along with the cities.

2. Create a view that combines data from the user and Events tables to display the name of each user
along with the event names.
20CS2016L - Database Management
Systems Lab URK22CS3013

3. Build a view that shows a summary of the number of events in each venue.

4. Display the 3 oldest users from the users table.


20CS2016L - Database Management
Systems Lab URK22CS3013

5. Display the last 5 events from the events table.

6. Create a sequence that generates unique user IDs starting from 1001 and incrementing by 1 for each
new user added to the users table. Add 3 new records using the sequence.

7. Display the current value of the sequence.


20CS2016L - Database Management
Systems Lab URK22CS3013

8. Alter the sequence to increment by 10. Add 3 records to the users table using the sequence.

9. Create an index on the userid column of the users table and check the access time with userid in the
where clause.

10. Create a synonym for the users table.


20CS2016L - Database Management
Systems Lab URK22CS3013

Result:
The other database objects like views, sequence, indexes and synonyms are created successfully.

You might also like