Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a virtual table in PostgreSQL?

In SQLite it is possible to make virtual tables based on things outside the database, as described in this article:

http://www.drdobbs.com/database/query-anything-with-sqlite/202802959

That's great, but I like the PostgreSQL command line client better than the one for SQLite. So, how can I make virtual tables in PostgreSQL?

like image 283
ijt Avatar asked Feb 09 '26 21:02

ijt


1 Answers

You want "foreign data wrappers" (often abbreviated "fdw"). There are a couple included in the core postgresql distribution: file_fdw, which allows you to create a table interface to files local to the DB, and postgres_fdw, which allows you to interface with other postgresql databases.

There are a number of community-written fdws, as well, for interacting with things like couchdb, mysql, or even amazon s3.

like image 53
jmelesky Avatar answered Feb 12 '26 15:02

jmelesky