2016-05-25 02:48:38 -05:00
|
|
|
.. _foreign_table_dialog:
|
|
|
|
|
2018-06-15 03:14:12 -05:00
|
|
|
*****************************
|
|
|
|
`Foreign Table Dialog`:index:
|
|
|
|
*****************************
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Foreign Table* dialog to define a foreign table in the current
|
|
|
|
database. Foreign tables define the structure of an external data source that
|
|
|
|
resides on a foreign server.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The *Foreign Table* dialog organizes the development of a foreign table through
|
|
|
|
the following dialog tabs: *General*, *Definition*, *Columns*, *Constraints*,
|
|
|
|
*Options*, and *Security*. The *SQL* tab displays the SQL code generated by
|
|
|
|
dialog selections.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
.. image:: images/foreign_table_general.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Use the fields in the *General* tab to identify the foreign table:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Name* field to add a descriptive name for the foreign table. The name
|
|
|
|
of the foreign table must be distinct from the name of any other foreign
|
|
|
|
table, table, sequence, index, view, existing data type, or materialized view
|
|
|
|
in the same schema. The name will be displayed in the *pgAdmin* tree control.
|
|
|
|
* Use the drop-down listbox next to *Owner* to select the name of the role that
|
|
|
|
will own the foreign table.
|
|
|
|
* Select the name of the schema in which the foreign table will reside from the
|
|
|
|
drop-down listbox in the *Schema* field.
|
2016-05-25 02:48:38 -05:00
|
|
|
* Store notes about the foreign table in the *Comment* field.
|
|
|
|
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/foreign_table_definition.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog definition tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Use the fields in the *Definition* tab to define the external data source:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the drop-down listbox next to *Foreign server* to select a foreign server.
|
|
|
|
This list is populated with servers defined through the *Foreign Server*
|
|
|
|
dialog.
|
|
|
|
* Use the drop-down listbox next to *Inherits* to specify a parent table. The
|
|
|
|
foreign table will inherit all of its columns. This field is optional.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Click the *Columns* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/foreign_table_columns.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog columns tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2021-05-11 05:16:38 -05:00
|
|
|
Use the fields in the *Columns* tab to add columns and their attributes to
|
2019-03-08 09:29:05 -06:00
|
|
|
the table. Click the *Add* icon (+) to define a column:
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
* Use the *Name* field to add a descriptive name for the column.
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the drop-down listbox in the *Data Type* field to select a data type for
|
|
|
|
the column. This can include array specifiers. For more information on which
|
|
|
|
data types are supported by PostgreSQL, refer to Chapter 8 of the core
|
|
|
|
documentation.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Click the *Add* icon (+) to specify each additional column; to discard a column,
|
|
|
|
click the trash icon to the left of the row and confirm deletion in the *Delete
|
|
|
|
Row* popup.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Click the *Constraints* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/foreign_table_constraints.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog constraints tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
|
|
|
|
|
|
|
Use the fields in the *Constraints* tab to apply a table constraint to the
|
|
|
|
foreign table. Click the *Add* icon (+) to define a constraint:
|
|
|
|
|
|
|
|
* Use the *Name* field to add a descriptive name for the constraint. If the
|
|
|
|
constraint is violated, the constraint name is present in error messages, so
|
|
|
|
constraint names like *col must be positive* can be used to communicate
|
|
|
|
helpful information.
|
|
|
|
* Use the *Check* field to write a check expression producing a Boolean result.
|
|
|
|
Each row in the foreign table is expected to satisfy the check expression.
|
|
|
|
* Check the *No Inherit* checkbox to specify that the constraint will not
|
|
|
|
propagate to child tables.
|
|
|
|
* Uncheck the *Validate* checkbox to disable validation. The database will not
|
|
|
|
assume that the constraint holds for all rows in the table.
|
|
|
|
|
|
|
|
Click the *Add* icon (+) to specify each additional constraint; to discard a
|
|
|
|
constraint, click the trash icon to the left of the row and confirm deletion in
|
|
|
|
he *Delete Row* popup.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Click the *Options* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/foreign_table_options.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog options tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the fields in the *Options* tab to specify options to be associated with
|
|
|
|
the new foreign table or one of its columns; the accepted option names and
|
|
|
|
values are specific to the foreign data wrapper associated with the foreign
|
|
|
|
server. Click the *Add* icon (+) to add an option/value pair.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Specify the option name in the *Option* field. Duplicate option names are not
|
|
|
|
allowed.
|
2018-01-11 10:58:30 -06:00
|
|
|
* Provide a corresponding value in the *Value* field.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Click the *Add* icon (+) to specify each additional option/value pair; to
|
|
|
|
discard an option, click the trash icon to the left of the row and confirm
|
|
|
|
deletion in the *Delete Row* popup.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Click the *Security* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/foreign_table_security.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog security tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2018-01-11 10:58:30 -06:00
|
|
|
Use the *Security* tab to assign privileges and define security labels.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Privileges* panel to assign privileges to a role. Click the *Add* icon
|
|
|
|
(+) to set privileges for database objects:
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Select the name of the role to which privileges will be assigned from the
|
|
|
|
drop-down listbox in the *Grantee* field.
|
|
|
|
* Click inside the *Privileges* field. Check the boxes to the left of one or
|
|
|
|
more privileges to grant the selected privilege to the specified user.
|
2019-11-25 21:03:59 -06:00
|
|
|
* The current user, who is the default grantor for granting the privilege, is displayed in the *Grantor* field.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Click the *Add* icon (+) to assign additional privileges; to discard a
|
|
|
|
privilege, click the trash icon to the left of the row and confirm deletion in
|
|
|
|
the *Delete Row* popup.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Security Labels* panel to define security labels applied to the
|
|
|
|
function. Click the *Add* icon (+) to add each security label selection:
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Specify a security label provider in the *Provider* field. The named provider
|
|
|
|
must be loaded and must consent to the proposed labeling operation.
|
|
|
|
* Specify a a security label in the *Security Label* field. The meaning of a
|
|
|
|
given label is at the discretion of the label provider. PostgreSQL places no
|
|
|
|
restrictions on whether or how a label provider must interpret security
|
|
|
|
labels; it merely provides a mechanism for storing them.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Click the *Add* icon (+) to assign additional security labels; to discard a
|
|
|
|
security label, click the trash icon to the left of the row and confirm deletion
|
|
|
|
in the *Delete Row* popup.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Your entries in the *Foreign Table* dialog generate a SQL command (see an
|
|
|
|
example below). Use the *SQL* tab for review; revisit or switch tabs to make
|
|
|
|
any changes to the SQL command.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Example
|
|
|
|
*******
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The following is an example of the sql command generated by user selections in
|
|
|
|
the *Foreign Table* dialog:
|
2016-05-25 02:48:38 -05:00
|
|
|
|
|
|
|
.. image:: images/foreign_table_sql.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Foreign table dialog sql tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The example shown demonstrates creating a foreign table *weblogs* with multiple
|
2021-09-26 11:33:11 -05:00
|
|
|
columns.
|
2016-05-25 02:48:38 -05:00
|
|
|
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click the *Info* button (i) to access online help.
|
2016-05-25 02:48:38 -05:00
|
|
|
* Click the *Save* button to save work.
|
2021-09-24 10:31:56 -05:00
|
|
|
* Click the *Close* button to exit without saving work.
|
2016-05-25 02:48:38 -05:00
|
|
|
* Click the *Reset* button to restore configuration parameters.
|