Thursday, April 18, 2019

SQL Database Objects

Database objects are used to store or reference data. Some of them are indexes, stored procedures, sequences, views and so on.

INDEXES :-

Indexes are of different types and they are as below

Single column index 
A single-column index is created based on only one table column.
The basic syntax is as follows.

CREATE INDEX INDEX_NAME ON TABLE_NAME (COLUMN_NAME);
OR
CREATE INDEX INDEX_EMP ON EMP1 (EMPNO);

Unique Indexes
A unique index does not allow any duplicate values to be inserted into the table. 
The basic syntax is as follows.

CREATE UNIQUE INDEX index_name
on table_name (column_name);

Composite Indexes
A composite index is an index on two or more columns of a table. 
Its basic syntax is as follows.

CREATE INDEX index_name
on table_name (column1, column2);

Implicit Indexes
Implicit indexes are indexes that are automatically created by the database server when an object is created.

To Drop Index 
Drop index index_name;


No comments:

Post a Comment

SUBQUERIES PRACTISE QUESTIONS

1. Write a SQL query to find those employees who receive a higher salary than the employee with ID 7369. SELECT * FROM EMP WHERE SAL >  (...