[go: up one dir, main page]

0% found this document useful (0 votes)
19 views4 pages

DBMS 6

The document discusses indexes, sequences, and synonyms in databases. It provides the definitions and purposes of indexes, sequences, and synonyms as well as SQL syntax examples for creating, rebuilding, deleting indexes and sequences and creating synonyms.

Uploaded by

pareshkumar3108
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)
19 views4 pages

DBMS 6

The document discusses indexes, sequences, and synonyms in databases. It provides the definitions and purposes of indexes, sequences, and synonyms as well as SQL syntax examples for creating, rebuilding, deleting indexes and sequences and creating synonyms.

Uploaded by

pareshkumar3108
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/ 4

Experiment : 6

Aim : Queries on Working with Index, Sequence, Synonyms.

Description : Index is used for faster retrieval of rows from a table. It can be used
implicitly or explicitly. Mainly, index is of two types:
Simple Index:
It is created on a single column. The syntax is:
CREATE INDEX indexname ON tablename(column);

Complex Index:
It is created on more than one column. The syntax is:
CREATE INDEX indexname ON tablename(columns);

Viewing the details of a user-defined index:

SELECT index_name, table_name FROM USER_INDEXES;


SELECT index_name, table_name FROM USER_INDEXES
WHERE table_name= ’Student’;

Rebuilding an Index:

When a table goes through changes, it is advisable to rebuild


indexes based on that table. The syntax is:
ALTER INDEX indexname REBUILD;
ALTER INDEX ids REBUILD;
We can create index on multiple columns (complex index)

Deleting Index:

Sequence:
Sequence is used to generate a sequence of numbers. The value generated can have a
maximum of 38 digits. Let’s suppose that sequence is a set of integers 1, 2, 3, … that are
generated and supported by some database systems to produce unique values on demands.
The minimum information required to generate numbers using a sequence are:

• The starting number


• The maximum number
• The increment value
The syntax for creating a sequence is:

START WITH initial_value


INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE | NOCYCLE ;
Synonyms:
A synonym provides another name for database object, referred to as original object,
that may exist on a local or another server. A synonym belongs to schema, name of
synonym should be unique. A synonym cannot be original object for an additional
synonym and synonym cannot refer to user-defined function. The query below results
in an entry for each synonym in database. This query provides details about synonym
metadata such as the name of synonym and name of the base object.
select *
from sys.synonyms ;
syntax:
CREATE SYNONYM synonymname
FOR servername.databasename.schemaname.objectname;
As we can see we created synonym ‘em’ for the table ‘empl’. While retrieving the table
data we can use any one of the names.

You might also like