Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e93ca161
Commit
e93ca161
authored
Jan 31, 2014
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some examples to the postgres_fdw documentation.
Michael Paquier
parent
384fbd1a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
doc/src/sgml/postgres-fdw.sgml
doc/src/sgml/postgres-fdw.sgml
+62
-0
No files found.
doc/src/sgml/postgres-fdw.sgml
View file @
e93ca161
...
...
@@ -375,6 +375,68 @@
</para>
</sect2>
<sect2>
<title>Examples</title>
<para>
Here is an example of creating a foreign table with
<literal>postgres_fdw</>. First install the extension:
</para>
<programlisting>
CREATE EXTENSION postgres_fdw;
</programlisting>
<para>
Then create a foreign server using <xref linkend="sql-createserver">.
In this example we wish to connect to a <productname>PostgreSQL</> server
on host <literal>192.83.123.89</literal> listening on
port <literal>5432</literal>. The database to which the connection is made
is named <literal>foreign_db</literal> on the remote server:
<programlisting>
CREATE SERVER foreign_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '192.83.123.89', port '5432', dbname 'foreign_db');
</programlisting>
</para>
<para>
A user mapping, defined with <xref linkend="sql-createusermapping">, is
needed as well to identify the role that will be used on the remote
server:
<programlisting>
CREATE USER MAPPING FOR local_user
SERVER foreign_server
OPTIONS (user 'foreign_user', password 'password');
</programlisting>
</para>
<para>
Now it is possible to create a foreign table with
<xref linkend="sql-createforeigntable">. In this example we
wish to access the table named <structname>some_schema.some_table</>
on the remote server. The local name for it will
be <structname>foreign_table</>:
<programlisting>
CREATE FOREIGN TABLE foreign_table (
id serial NOT NULL,
data text
)
SERVER foreign_server
OPTIONS (schema_name 'some_schema', table_name 'some_table');
</programlisting>
It's essential that the data types and other properties of the columns
declared in <command>CREATE FOREIGN TABLE</> match the actual remote table.
Column names must match as well, unless you attach <literal>column_name</>
options to the individual columns to show how they are named in the remote
table.
</para>
</sect2>
<sect2>
<title>Author</title>
<para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment