![]() | ![]() |
Home |
|
|
Access Service User's Guide DirectConnect for AS/400 |
|
| Chapter 12 Accessing catalog information with CSPs |
|
| sp_pkeys |
Returns primary key information for the specified table or tables.
sp_pkeys table_name [, table_owner] [, table_qualifier]
is the name of the table. Wildcard-character search patterns are not supported. Views are not supported.
table_owneris the name of the collection if the CSPCatalogQualifier property value is QSYS2. Otherwise, this parameter can be ignored, set to NULL, or set to the value of the CSPCatalogQualifier property.
table_qualifieris ignored. Leave blank or set to NULL.
This function corresponds to the ODBC function SQLPrimaryKeys.
Information is based on the SYSINDEXES and SYSKEYS system catalog tables.
For information about creating a foreign key, see the appropriate IBM AS/400 DB2/400 SQL Reference.
sp_pkeys returns a row for each column in the primary key. Results are ordered by:
TABLE_OWNER
TABLE_NAME
KEY_SEQ
The lengths for varchar columns shown in the result set tables are maximums; the actual lengths depend on the target database.
The following table shows the result set.
Column | Datatype | Description |
TABLE_QUALIFIER | varchar(128) | NULL |
TABLE_OWNER | varchar(128) | Name of the collection in which the primary key table resides or NULL |
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 |
|
|