Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

primarykeys

Get primary key information for database table or schema

Syntax

k = primarykeys(dbmeta, 'cata', 'sch')
k = primarykeys(dbmeta, 'cata', 'sch', 'tab')

Description

k = primarykeys(dbmeta, 'cata', 'sch') returns primary key information for all tables in the schema sch, of the catalog cata, for the database whose database metadata object is dbmeta.

k = primarykeys(dbmeta, 'cata', 'sch', 'tab') returns primary key information for the table tab, in the schema sch, of the catalog cata, for the database whose database metadata object is dbmeta.

Examples

Get primary key information for the DEPT table:

k = primarykeys(dbmeta,'orcl','SCOTT','DEPT')
k = 
   'orcl'   'SCOTT'   'DEPT'   'DEPTNO'   '1'   'PK_DEPT'

The results show the primary key information as described in the following table.

ColumnDescriptionValue

1

Catalog

orcl

2

Schema

SCOTT

3

Table

DEPT

4

Column name of primary key

DEPTNO

5

Sequence number within primary key

1

6

Primary key name

PK_DEPT

Related Examples

Introduced before R2006a

Was this topic helpful?