]> begriffs open source - ai-pg/blob - full-docs/man3/dblink_get_pkey.3
Include links to all subsection html pages, with shorter paths too
[ai-pg] / full-docs / man3 / dblink_get_pkey.3
1 '\" t
2 .\"     Title: dblink_get_pkey
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "DBLINK_GET_PKEY" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 dblink_get_pkey \- returns the positions and field names of a relation\*(Aqs primary key fields
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 dblink_get_pkey(text relname) returns setof dblink_pkey_results
36 .fi
37 .SH "DESCRIPTION"
38 .PP
39 \fBdblink_get_pkey\fR
40 provides information about the primary key of a relation in the local database\&. This is sometimes useful in generating queries to be sent to remote databases\&.
41 .SH "ARGUMENTS"
42 .PP
43 \fIrelname\fR
44 .RS 4
45 Name of a local relation, for example
46 foo
47 or
48 myschema\&.mytab\&. Include double quotes if the name is mixed\-case or contains special characters, for example
49 "FooBar"; without quotes, the string will be folded to lower case\&.
50 .RE
51 .SH "RETURN VALUE"
52 .PP
53 Returns one row for each primary key field, or no rows if the relation has no primary key\&. The result row type is defined as
54 .sp
55 .if n \{\
56 .RS 4
57 .\}
58 .nf
59 CREATE TYPE dblink_pkey_results AS (position int, colname text);
60 .fi
61 .if n \{\
62 .RE
63 .\}
64 .sp
65 The
66 position
67 column simply runs from 1 to
68 \fIN\fR; it is the number of the field within the primary key, not the number within the table\*(Aqs columns\&.
69 .SH "EXAMPLES"
70 .sp
71 .if n \{\
72 .RS 4
73 .\}
74 .nf
75 CREATE TABLE foobar (
76     f1 int,
77     f2 int,
78     f3 int,
79     PRIMARY KEY (f1, f2, f3)
80 );
81 CREATE TABLE
82
83 SELECT * FROM dblink_get_pkey(\*(Aqfoobar\*(Aq);
84  position | colname
85 \-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-
86         1 | f1
87         2 | f2
88         3 | f3
89 (3 rows)
90 .fi
91 .if n \{\
92 .RE
93 .\}