You are on page 1of 1

SQL

I. What do you understand by indexing in terms of database?


In database systems, an index (IDX) is a data structure defined on columns in a database table to
significantly speed up data retrieval operations. An index is a small copy of a database table sorted by key
values. Without an index, query languages like SQL may have to scan the entire table from top to bottom to
choose relevant rows.

II. How you will create index?


CREATE INDEX index_name
ON table_name (column_name)

III. What do you understand by View in sql and how you will create?
Views can be considered as virtual tables. Generally speaking, a table has a set of definition, and it physically
stores the data. A view also has a set of definitions, which is build on top of table(s) or other view(s), and it
does not physically store the data.
The syntax for creating a view is as follows:
CREATE VIEW "VIEW_NAME" AS "SQL Statement";

IV. Which data type VARCHAR or int better to store unique id in sql and why?
An int is usually better because it gives better performance.
It is faster and uses less storage on the database.

V. SQL query to get max salary ?


select MAX(Salary) from Employee;

You might also like