Views are virtual tables that are used primarily for ease of use and security, such as:
- Filter and filter rows by criteria
- Protect sensitive data
- Reduce complexity
- Abstract Logical Database
You need to be aware when working with views:
- The view can contain multiple tables
- Views can be created again based on the view
- The view also allows additions and deletions to change
- If you sort order BY, you must use the top keyword
- Cannot appear in keyword
- Cannot appear variable
Syntax for creating views
create view View_detail as select G.id as gid, g.name as Gname, c.id as CID, c.name as CNAME from grade G, Corse c where g.id = C.gradeid go
Create View View_report as Select count (1 as Corsenum from View_detail Group by GID Go
Indexes are techniques used to improve query efficiency, primarily with primary key indexes (automatically becoming clustered indexes), unique indexes (no duplicates allowed), clustered indexes (one table only), nonclustered indexes, etc.
Create an indexed statement
Create nonclustered Index on with FillFactor = -
Where FILLFACTOR is the fill factor, the default 30%
The statement that displays the specified index is:
Select * from Student with (index=idx_studentname) where like ' %s% '
Some guidelines for creating indexes:
Frequently-found fields frequently sorted as fields of the query criteria, or fields that are grouped frequently as joins (primary foreign key) are generally not required to create an index when the following conditions are present, otherwise the data in the Execution efficiency table will be affected less than the fields in the table have fixed options
Data Definition Language DDL-View index