sp_indexes (języka Transact-SQL)
Zwraca indeks informacji dla określonego tabela zdalna.
sp_indexes [ @table_server = ] 'table_server'
[ , [@table_name = ] 'table_name' ]
[ , [ @table_schema = ] 'table_schema' ]
[ , [ @table_catalog = ] 'table_db' ]
[ , [ @index_name = ] 'index_name' ]
[ , [ @is_unique = ] 'is_unique' ]
Argumenty
[ @table_server = ] 'table_server'
Is the name of a linked server running SQL Server for which table information is being requested.table_server is sysname, with no default.[ @table_name = ] 'table_name'
Is the name of the remote table for which to provide index information.table_name is sysname, with a default of NULL.Jeśli wartością tą jest NULL, zwracane są wszystkie tabele w określonej bazie danych.[ @table_schema = ] 'table_schema'
Określa schemat tabela.In the SQL Server environment, this corresponds to the table owner.table_schema is sysname, with a default of NULL.[ @table_catalog = ] 'table_db'
Is the name of the database in which table_name resides.table_db is sysname, with a default of NULL.Jeśli wartością tą jest NULL, table_db Domyślnie: master.[ @index_name = ] 'index_name'
Is the name of the index for which information is being requested.index is sysname, with a default of NULL.[ @is_unique = ] 'is_unique'
Is the type of index for which to return information.is_unique is bit, with a default of NULL, and can be one of the following values.Wartość
Description
1
Zwraca informacje o unikatowe indeksy.
0
Zwraca informacje o indeksach, które nie są unikatowe.
WARTOŚCI NULL
Zwraca informacje o wszystkich indeksów.
Zestawy wyników
Nazwa kolumna |
Typ danych |
Description |
|---|---|---|
TABLE_CAT |
sysname |
Nazwa bazy danych, w którym znajduje się w określonej tabela. |
TABLE_SCHEM |
sysname |
Schemat dla tabela. |
NAZWA_TABELI |
sysname |
Nazwa tabela zdalnej. |
NON_UNIQUE |
smallint |
Czy indeks jest unikatowy i nie jest unikatowa: 0 = Unikatowe 1 = Nie unikatowe |
INDEX_QUALIFER |
sysname |
Nazwa właściciela indeksu.Niektóre produkty DBMS umożliwiają użytkowników innych niż właściciel tabela do tworzenia indeksów.W SQL Server, to kolumna jest zawsze taka sama, jak NAZWA_TABELI. |
INDEX_NAME |
sysname |
Nazwa indeksu. |
TYP |
smallint |
Typ indeksu: 0 = Statystyki dla tabela 1 = Clustered 2 = Hashed 3 = Inne |
ORDINAL_POSITION |
int |
Liczba porządkowa pozycję kolumna w indeksie.Pierwsza kolumna w indeksie wynosi 1.To kolumna zawsze zwraca wartość. |
NAZWA_KOLUMNY |
sysname |
Jest nazwą odpowiedniej kolumna dla każdej kolumna z NAZWA_TABELI zwracane. |
ASC_OR_DESC |
varchar |
Kolejność jest stosowana podczas sortowanie: A = rosnąco D = malejąco Wartość NULL = nie dotyczy SQL Server zawsze zwraca A. |
RELACJA |
int |
To liczba wierszy w tabela lub unikatowych wartości w indeksie. |
STRONY |
int |
Jest to liczba stron do przechowywany indeks lub tabela. |
FILTER_CONDITION |
nvarchar(4000) |
SQL Server nie zwraca wartości. |
Uprawnienia
Wymaga uprawnienie SELECT do schematu.
Przykłady
W poniższym przykładzie są zwracane wszystkie informacje o indeksach z Employees spis AdventureWorks bazy danych na Seattle1 serwer połączony.
EXEC sp_indexes @table_server = 'Seattle1',
@table_name = 'Employee',
@table_schema = 'HumanResources',
@table_catalog = 'AdventureWorks'
See Also
.gif)