Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all foreign servers?

Tags:

How to list all foreign servers in a Postgres database from psql command line? Servers can be created by create server

like image 778
Andong Zhan Avatar asked May 24 '17 23:05

Andong Zhan


People also ask

How do I list all PostgreSQL servers?

Summary. Use \l or \l+ in psql to show all databases in the current PostgreSQL server.

What is foreign server?

A Foreign Server represents a JNDI provider that is outside WebLogic server. It contains information that allows a local WebLogic Server instance to reach a remote JNDI provider, thereby allowing for a number of foreign connection factory and destination objects to be defined on one JNDI directory.

How do I list databases in PostgreSQL?

Step 1: Log in to the server using the SQL Shell (psql) app. Step 2: Run the following query: SELECT datname FROM pg_database; psql runs the query against the server and displays a list of existing databases in the output.


1 Answers

You can query the system catalog pg_foreign_server, e.g.:

select      srvname as name,      srvowner::regrole as owner,      fdwname as wrapper,      srvoptions as options from pg_foreign_server join pg_foreign_data_wrapper w on w.oid = srvfdw;        name      |  owner   |   wrapper    |                options                  ----------------+----------+--------------+----------------------------------------  csv_server     | postgres | file_fdw     |   foreign_server | postgres | postgres_fdw | {host=localhost,port=5432,dbname=test} (2 rows) 
like image 185
klin Avatar answered Sep 18 '22 09:09

klin