提高資料收索效率-索引應用

來源:互聯網
上載者:User
1.sql server索引是一個單獨的,物理的資料結構,為了加速對錶中資料行的索引建立的一種分散的儲存結構。
2.資料查詢時在表中一行一行的查詢,因為了為了提高效率就直接在這列上定義索引
3.優點如下
加強資料檢索,加速連結,order by. group by等需要進行資料檢索,查詢最佳化工具依賴於索引,唯一性索引
4.索引分類:叢集索引,非叢集索引,唯一性索引,包含性列索引,索引檢視表,全文索引,xml
5.建立索引需要注意
一:列中的資料沒有重複的,也不能有兩行空的
二:每個表只能有一個叢集索引,可以由多個非叢集索引最多249個
三:需要考慮許可權,空間的問題
---建立一個唯一性的非叢集索引
use Teach
go
(
--nonclustered指定為非叢集索引
create unique nonclustered
index tname_index on TeachInfo(tname)
)
其中:tname_index表示索引名, teachInfo表示表
==
建立索引檢視表
--建立索引檢視表一般用唯一性,叢集索引
use Teach
go
--用set設定它的選項
set numeric_Roundabort off
set ansi_radding ansi_warnings, concat_null_yields_null, arithabort quoted_identifier, ansi_nulls on
go
create view teach_View
with schenabinding
as
select tno, tname form teachinfo, teachclass where teachingo.no=teachclass.no
go
create unique clustered
index tdx_v1
on teachInfo(Tno)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.