Data Definition Language DDL-View index

Source: Internet
Author: User
Tags one table

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.