sp_pkeys

Description

Returns primary key information for the specified table or tables.

Syntax

sp_pkeys table_name [, table_owner]
 [, table_qualifier]

Parameters

table_name

is the name of the table. Wildcard-character search patterns are not supported. Views and aliases are not supported.

table_owner

is the owner of the table. Wildcard-character search patterns are not supported. If you do not specify this parameter, sp_fkeys looks first for a table owned by the current user and then for a table owned by the database owner.

table_qualifier

is ignored. Leave blank or set to NULL.

Usage


Results

sp_pkeys returns a row for each column in the primary key. Results are ordered by:

The lengths for varchar columns shown in the result set tables are maximums; the actual lengths depend on the target database.

Table 11-10 shows the result set.

Table 11-10: Result set for sp_pkeys

Column

Datatype

Description

TABLE_QUALIFIER

varchar(128)

NULL

TABLE_OWNER

varchar(128)

Primary key table owner (authorization ID)

TABLE_NAME

varchar(128)

NOT NULL

Primary key table name

COLUMN_NAME

varchar(128)

NOT NULL

Primary key column name

KEY_SEQ

smallint

NOT NULL

Sequence number of the column in a multi-column primary key

PK_NAME

varchar(128)

Primary key identifier; NULL if not applicable to the target database