sql-server basics four (views and indexes)

1. Create a view

The view is established for the efficiency of the query. The view is only a part of the data of the table, and the query speed will be faster than directly querying a table.

The view can only display the data you need, and the unneeded data can not disappear, so the idea of ​​directly operating the view query is clearer than directly operating the basic table.


Create a view of the School of Information students

create view is_student

as

select Sno, Sname, Sage

from student

where Sdept='Information Institute'

with check option;

2. Create an index

Establishing a unique index in ascending order of student numbers also improves the query rate.

create unique index Stusno on student(Snow);



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325605908&siteId=291194637