sp_iqpkeys procedure

Function

Displays information about primary keys and primary key constraints by table, column, table owner, or for all Sybase IQ tables in the database.

Syntax

sp_iqpkeys { [ table-name ], [ column-name ], [ table-owner ] }

Permissions

None required.

Usage

table-name The name of a base or global temporary table. If specified, the procedure returns information about primary keys defined on the specified table only.

column-name The name of a column. If specified, the procedure returns information about primary keys on the specified column only.

table-owner The owner of a table or table. If specified, the procedure returns information about primary keys on tables owned by the specified owner only.

One or more of the parameters can be specified. If you do not specify either of the first two parameters, but specify the next parameter in the sequence, you must substitute NULL for the omitted parameters. If none of the parameters are specified, a description of all primary keys on all tables in the database is displayed. If any of the specified parameters is invalid, no rows are displayed in the output.

Table 10-33: sp_iqpkeys usage examples

Syntax

Output

sp_iqpkeys sales

Displays information about primary keys defined on table sales

sp_iqpkeys sales, NULL, DBA

Displays information about primary keys defined on table sales owned by DBA

sp_iqpkeys sales, store_id, DBA

Displays information about primary key defined on column store_id of table sales owned by DBA

sp_iqpkeys NULL, NULL, DBA

Displays information about primary keys defined on all tables owned by DBA

See also

“sp_iqindex and sp_iqindex_alt procedures”

“sp_iqcolumn procedure”

Description

The sp_iqpkeys stored procedure displays the following information about primary keys on base and global temporary tables in a database:

Table 10-34: sp_iqpkeys columns

Column name

Description

table_name

The name of the table

table_owner

The owner of the table

column_name

The name of the column(s) on which the primary key is defined

column_id

The column ID

constraint_name

The name of the primary key constraint

constraint_id

The primary key constraint ID

NoteThe sp_iqpkeys stored procedure exists only in databases created with Sybase IQ version 12.6 or later.

Examples

Display the primary keys defined on columns of table sales1:

sp_iqpkeys sales1

table_name table_owner column_name column_id constraint_name constraint_id
sales1         DBA        store_id     1         MA114           114

Display the primary keys defined on columns of table sales2:

sp_iqpkeys sales2

table_name table_owner column_name column_id constraint_name constraint_id
sales2         DBA      store_id,     1,2        MA115           115
                        order_num

Display the primary keys defined on the column store_id of table sales2:

sp_iqpkeys sales2, store_id

table_name table_owner column_name column_id constraint_name constraint_id
sales2         DBA      store_id       1         MA115           115