1DBLINK_GET_PKEY(3)       PostgreSQL 13.4 Documentation      DBLINK_GET_PKEY(3)
2
3
4

NAME

6       dblink_get_pkey - returns the positions and field names of a relation's
7       primary key fields
8

SYNOPSIS

10       dblink_get_pkey(text relname) returns setof dblink_pkey_results
11

DESCRIPTION

13       dblink_get_pkey provides information about the primary key of a
14       relation in the local database. This is sometimes useful in generating
15       queries to be sent to remote databases.
16

ARGUMENTS

18       relname
19           Name of a local relation, for example foo or myschema.mytab.
20           Include double quotes if the name is mixed-case or contains special
21           characters, for example "FooBar"; without quotes, the string will
22           be folded to lower case.
23

RETURN VALUE

25       Returns one row for each primary key field, or no rows if the relation
26       has no primary key. The result row type is defined as
27
28           CREATE TYPE dblink_pkey_results AS (position int, colname text);
29
30       The position column simply runs from 1 to N; it is the number of the
31       field within the primary key, not the number within the table's
32       columns.
33

EXAMPLES

35           CREATE TABLE foobar (
36               f1 int,
37               f2 int,
38               f3 int,
39               PRIMARY KEY (f1, f2, f3)
40           );
41           CREATE TABLE
42
43           SELECT * FROM dblink_get_pkey('foobar');
44            position | colname
45           ----------+---------
46                   1 | f1
47                   2 | f2
48                   3 | f3
49           (3 rows)
50
51
52
53PostgreSQL 13.4                      2021                   DBLINK_GET_PKEY(3)
Impressum